I'm experiencing a problem though:
I have a variable $error in my HTML which is suppose to print an error message if the user leaves either his first name or password blank upon signing up for the site. The PHP is working fine. I'm debugging it, and all the right echo statements I'm using to debug are printing. The problem is in the HTML. It's not showing $error at all.
Here's the code:
HTML:
<div id="signsection"> <pre> <form method='post' action='testApple.php' class="signup"> <fieldset> <legend>Create an Account</legend> <div> <span class="names">First Name</span> <input class="signForm" type='text' name='fName' /><br /> <span class="names">Last Name</span> <input class="signForm" type='text' name='lName' /><br /> <span class="names">Email Address</span> <input class="signForm" type='text' name='emailA' /><br /> <span class="names">Password</span> <input class="signForm" type='password' name='pass' /><br /> <input class="signButton" type='image' src="GuestbookAi3.gif" value='Create Account' /> </div> </fieldset> </form> </pre> </div> <div id="error"> <?php echo $error ?> </div>
And here's the corresponding PHP:
<?php // Page that allows users to join the network
include_once("index_layout.php");// used to include the basic header that is on every page, and to use any functions we may need from znfunctions.php
include_once("appleFunctions.php");
$error = $user = $pass = "";
if(isset($_SESSION['user'])) destorySession();// if the session variable $_SESSION['user'] has been set, destroy it
if(isset($_POST['fName']))// if the form has been submitted $POST['user'] will have a value
{
echo "hello";
$user = sanitizeString($_POST['fName']);// so if it's been submitted, set $user to the sanitized version of whatever was in the user field
$pass = sanitizeString($_POST['pass']);// if it's been submitted, set $pass to the sanitized version of whatever was in the user field
if($user == "")
{
echo "sdfhskjfhs";
}
echo $user ;
// username and password validation
if($user == "" || $pass == "")// if either of the fields were left blank..
{
echo "here";
$error = "Not all fields were entered<br /><br />";// set $error to an error message
}
else// if neither of the fields were left blank...
{
$query = "SELECT * FROM znmembers WHERE user='$user'";// a query to find a user with the name that was submitted in the form that wasn't blank
if(mysql_num_rows(queryMysql($query)))// call queryMysql to get the results of the above query. If there aren't zero rows the name has been taken
{
$error = "That username already exists<br /><br />";// set $error to an $error message
}
else// if the username entered wasn't already taken..
{
$query = "INSERT INTO znmembers VALUES('$user', '$pass')";// a query to inset the submitted username and password into the znmembers table
queryMysql($query);// perform the query
die("<h4>Accout created</h4>You may now Log in.");
}
}
}
?>
Can't seem to figure out what's going wrong.
Thank you!
EDIT: Sorry. Stupid me forget to include the php page in the HTML page.
This post has been edited by eZACKe: 23 May 2011 - 02:30 PM

New Topic/Question
Reply




MultiQuote




|