473,383 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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_validate.php">
<h2>User Profile</h2>
<?php

// Show meaningful instructions for UPDATE or INSERT or errors
if(empty($errors))
{
if (session_is_registered("loginUsername"))
{
echo "<p><b>Please update your profile below as
needed:</b></p>";
}
else
{
echo "<p><b>Please 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("userName", $errors); ?>
<input type="text" name="userName"
value="<? echo $formVars["userName"]; ?>"
size=25></td>
</tr>

<tr><td>Real Name:</td>
<td><? echo fieldError("realName", $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("city", $errors); ?>
<input type="text" name="city"
value="<? echo $formVars["city"]; ?>"
size=20></td>
</tr>

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

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

<tr><td>Country:</td>
<td><? echo fieldError("country", $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_registered("loginUsername"))
{
? <tr><td>Email:</td>
<td><? echo fieldError("email", $errors); ?>
<input type="text" name="email"
value="<? echo $formVars["email"]; ?>"
size=50></td>
</tr>

<tr><td>Password:</td>
<td><? echo fieldError("loginPassword", $errors); ?>
<input type="password" name="loginPassword"
value="<? echo $formVars["loginPassword"]; ?>"
size=8></td>
</tr>

<tr><td><img src="/captcha.php"></td>
<td><? echo fieldError("loginCaptcha", $errors); ?>
Type in the text from the image to the left<br/>
<input type="text" name="loginCaptcha"
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_unregister("formVars");
session_unregister("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_registered("errors"))
session_register("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_registered("formVars"))
session_register("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["loginPassword"] = clean($_POST["loginPassword"], 50);
$formVars["loginCaptcha"] = clean($_POST["loginCaptcha"], 50);

....
?>

Jul 31 '06 #1
1 6976
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
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. ...
1
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...
4
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...
10
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) ...
24
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...
4
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...
1
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...
2
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...
6
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.