473,545 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problems with $_POST returning NULL values in php 4.4.2

okay. so all i am doing is changing a registration script that uses
$_GET to a script that uses $_POST, but the validation script now
returns NULL values for all posted vars.

What's the deal?

NOTE: when i use $_GET the script just works.

Thanks in advance for helping a noob.

script with the form:
<?php
// Connect to a session
session_start( );
?>
<form method="POST" action="reg_val idate.php">
<h2>User Profile</h2>
<?php

// Show meaningful instructions for UPDATE or INSERT or errors
if(empty($error s))
{
if (session_is_reg istered("loginU sername"))
{
echo "<p><b>Plea se update your profile below as
needed:</b></p>";
}
else
{
echo "<p><b>Plea se fill in all details below to
join.</b></p>";
}
}else{
// Display error message to the user
showMessage();
}
?>
<table>
<col span="1" align="right">

<tr><td>User Name:</td>
<td><? echo fieldError("use rName", $errors); ?>
<input type="text" name="userName"
value="<? echo $formVars["userName"]; ?>"
size=25></td>
</tr>

<tr><td>Real Name:</td>
<td><? echo fieldError("rea lName", $errors); ?>
<input type="text" name="realName"
value="<? echo $formVars["realName"]; ?>"
size=25></td>
</tr>

<tr><td>Sex:</td>
<td><select name="title">
<option <?php if ($formVars["sex"]=="M")
echo "selected"; ?>>M
<option <?php if ($formVars["sex"]=="F")
echo "selected"; ?>>F
</select><br></td>
</tr>

<tr><td>City: </td>
<td><? echo fieldError("cit y", $errors); ?>
<input type="text" name="city"
value="<? echo $formVars["city"]; ?>"
size=20></td>
</tr>

<tr><td>State :</td>
<td><? echo fieldError("sta te", $errors); ?>
<input type="text" name="state"
value="<? echo $formVars["state"]; ?>"
size=20></td>
</tr>

<tr><td>Zipcode :</td>
<td><? echo fieldError("zip code", $errors); ?>
<input type="text" name="zipcode"
value="<? echo $formVars["zipcode"]; ?>"
size=5></td>
</tr>

<tr><td>Country :</td>
<td><? echo fieldError("cou ntry", $errors); ?>
<input type="text" name="country"
value="<? echo $formVars["country"]; ?>"
size=5></td>
</tr>

<tr><td>Date of birth (dd/mm/yyyy): </td>
<td><? echo fieldError("dob ", $errors); ?>
<input type="text" name="dob"
value="<? echo $formVars["dob"]; ?>"
size=10></td>
</tr>

<?php
// Only show the username/email and password
// <inputwidgets to new users
if (!session_is_re gistered("login Username"))
{
? <tr><td>Email :</td>
<td><? echo fieldError("ema il", $errors); ?>
<input type="text" name="email"
value="<? echo $formVars["email"]; ?>"
size=50></td>
</tr>

<tr><td>Passwor d:</td>
<td><? echo fieldError("log inPassword", $errors); ?>
<input type="password" name="loginPass word"
value="<? echo $formVars["loginPassw ord"]; ?>"
size=8></td>
</tr>

<tr><td><img src="/captcha.php"></td>
<td><? echo fieldError("log inCaptcha", $errors); ?>
Type in the text from the image to the left<br/>
<input type="text" name="loginCapt cha"
value="" size=8></td>
</tr>

<?php
}
?>
<tr>
<td><input type="submit" value="Submit"> </td>
</tr>
</table>
</form>
<?php
foot();
//prevent session hijacks by clearing sessions once
informations is
displayed
// Clear the formVars so a future <formis blank
session_unregis ter("formVars") ;
session_unregis ter("errors");
?>

validation snippet:
(not including all the validation just the meat where the vars are
being grabbed)

<?php
// Initialize a session
session_start() ;

// Register an error array - just in case!
if (!session_is_re gistered("error s"))
session_registe r("errors");

// Clear any errors that might have been
// found previously
$errors = array();
$formVars = array();

// Set up a $formVars array with the POST variables
// and register with the session.
if (!session_is_re gistered("formV ars"))
session_registe r("formVars") ;

// TO DO remove $HTTP_GET_VARS and use all $_GET variables
// TO DO use $_POST
$formVars["userName"] = clean($_POST["userName"],50);
$formVars["realName"] = clean($_POST["realName"], 50);
$formVars["sex"] = clean($_POST["sex"], 50);
$formVars["city"] = clean($_POST["city"], 50);
$formVars["state"] = clean($_POST["state"], 50);
$formVars["zipcode"] = clean($_POST["zipcode"], 50);
$formVars["country"] = clean($_POST["country"], 50);
$formVars["dob"] = clean($_POST["dob"], 50);
$formVars["email"] = clean($_POST["email"], 50);
$formVars["loginPassw ord"] = clean($_POST["loginPassw ord"], 50);
$formVars["loginCaptc ha"] = clean($_POST["loginCaptc ha"], 50);

....
?>

Jul 31 '06 #1
1 6986
figured out a workaround for $_POST

instead of calling $_POST while assigning to my session array
$form_vars like this:
$formVars["userName"] = clean($_POST["userName"],50);

i call $_POST to a normal var $userName like this:
$userName = $_POST["userName"];

then do
$formVars["userName"] = clean($userName ,50);

however, this does not explain why
$formVars["userName"] = clean($_GET["userName"],50);

works when using get method while
$formVars["userName"] = clean($_POST["userName"],50);

doesn't when using post method.

so flummoxed,
raymond

Jul 31 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1951
by: Dariusz | last post by:
I have a small form that on button press submits to a PHP file for further processing into a database. I have to change the script as it allows blank / nothing to be submitted to the database. The intention is that if any of the two form fields are blank (empty) then the page is resent stating that they have to fill in all the fields to post...
1
2220
by: Mattt | last post by:
Hi, I've run into a rather odd problem. get Methods seem to return values from the wrong methods! For example, let's pretend my activex control stores values about a person. getName would return their age, while getAge might return null! Something is also going wrong with my method that accepts input and returns a value (okay, it is a money...
4
2016
by: Ellen Manning | last post by:
Using SQL2000. I want to return the # of columns with non-null values. Here's my query so far: select case when Dx1 is not null then 0 else 1 end + case when Dx2 is not null then 0 else 1 end + case when Dx3 is not null then 0 else 1 end + case when Dx4 is not null then 0 else 1 end as DxCount from tblClerkshipDataClean where PalmName...
10
2388
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ComboBox.SelectedValue = db_value; If the db_value was not included in the ComboBox value list the ComboBox.SelectedIndex used to return -1, Now the very same code is
24
2860
by: moriman | last post by:
Hi, The script below *used* to work. I have only just set up a server, PHP etc again on my Win98 system and now it doesn't? On first loading this page, you would have $p = and the button image below it.
4
1645
by: so many sites so little time | last post by:
ok so i am having problems if you look at the script below you will see that it the query has 4 values to insert but the actual values only contain title entry and now() for the date. well i have made the database and the blog_id is a primary auto interger what ever table bascly look below the the insert code block to find the code block...
1
1407
by: Nosferatum | last post by:
I intend to upload documents (file_up), categorize them in 4 main categories (k_cat), have additional sub-categories (lec_cat) just for querying and getting sub-categorized output of the files when listed with date (dato_inn) and the submitters details "uploaded_by". But my script will not work. Anyone clever out there seeing what's wrong?...
2
2583
tolkienarda
by: tolkienarda | last post by:
hi everyone i am getting a bunch of values from a form via post all of the information that this question deals with is from series of check boxes below is the code that creates the check boxes the logic behind it is it gets a bunch of listing from the database and if $group is not null then the first check box is checked and a second created...
6
2165
by: fpcreator2000 | last post by:
Hello everyone. I'm having problems with a page I've created that is used to insert data into a database. It uploads two files into two distinct folder, and it takes the filenames and inserts them into a MYSQL database along with other product information. Here is the entire .php file. I list it because the errors are not showing at all, and...
0
7669
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7926
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7439
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3468
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.