473,769 Members | 5,724 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 6994
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
1956
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 (to a database). If I deliberately leave the fields blank and submit the form, querying the...
1
2229
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 conversion program!)... it is returning null! They are consistently returning the same, wrong...
4
2025
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 = @PalmName
10
2416
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
2884
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
1654
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 that makes the table in the database, // Define the query. $query = "INSERT INTO blog_entries...
1
1420
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? This is my upload form, the script at the bottom:
2
2600
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 else only one unchecked checkbox is created $result=mysql_query("SELECT TITLE, FNMI, LN,...
6
2179
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 I need a fresh pair of eyes to look at it. Any answers, critisims (constructive), or other talk...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9994
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5298
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.