aerouk Posted June 15, 2008 Share Posted June 15, 2008 Hey all, I'm a little stuck with a form that I'm playing with at the moment. Just a few fields with a small bit of validation. However I seem to keep being faced with the deaded WPE! Could someone please let me know whats going on with the below? if(isset($_POST['submit'])){ # connect to the database here include('db.php'); # search the database to see if the user name has been taken or not $sql= mysql_query("SELECT * FROM ffl_managers WHERE userName='{$_POST['user_name']}' LIMIT 1"); $row = mysql_fetch_array($sql)or die(mysql_error()); #check to see what fields have been left empty, and if the passwords match if($row||empty($_POST['user_name'])|| empty($_POST['fname'])||empty($_POST['lname'])|| empty($_POST['email'])||empty($_POST['password'])|| empty($_POST['re_password'])||$_POST['password']!=$_POST['re_password']){ # if a field is empty, or the passwords don't match make a message if(empty($_POST['user_name'])){ $user = 'User Name cant be empty<br>'; } if(empty($_POST['fname'])){ $fname = 'First Name cant be empty<br>'; } if(empty($_POST['lname'])){ $lname = 'Last Name cant be empty<br>'; } if(empty($_POST['email'])){ $email = 'Email cant be empty<br>'; } if(empty($_POST['password'])){ $password = 'Password cant be empty<br>'; } if(empty($_POST['re_password'])){ $re_password = 'You must re-type your password<br>'; } if($row){ $user_name_exist = 'User Name already exists<br>'; } if($_POST['password']!=$_POST['re_password']){ $password_match = 'Passwords dont match<br>'; } }else{ # If all fields are not empty, and the passwords match, # create a session, and session variables, # register_accept will be checked on the next page to see # if the user came from this page. session_start(); $_SESSION['user_name'] = $_POST['user_name']; $_SESSION['fname'] = $_POST['fname']; $_SESSION['lname'] = $_POST['lname']; $_SESSION['email'] = $_POST['email']; $_SESSION['password'] = $_POST['password']; $_SESSION['memorable_word'] = $_POST['memorable_word']; $_SESSION['register_accept'] = 1; header("Location: confirm_join.php"); exit; } } # echo out each variable that was set from above, # then destroy the variable. if(isset($user)){ echo $user; unset($user); } if(isset($fname)){ echo $fname; unset($fname); } if(isset($lname)){ echo $lname; unset($lname); } if(isset($email)){ echo $email; unset($email); } if(isset($password)){ echo $password; unset($password); } if(isset($re_password)){ echo $re_password; unset($re_password); } if(isset($user_name_exist)){ echo $user_name_exist; unset($user_name_exist); } if(isset($password_match)){ echo $password_match; unset($password_match); } if(isset($memorable_word)){ echo $memorable_word; unset($memorable_word); } ?> <!-- Start your HTML/CSS/JavaScript here --> <form action="registration.php" method="post"> <p>First Name:<br><input type="text" name="fname" <? echo 'value="'.$_POST['fname'].'"'; ?></p> <p>Last Name:<br><input type="text" name="lname" <? echo 'value="'.$_POST['lname'].'"'; ?></p> <p>Email:<br><input type="text" name="email" <? echo 'value="'.$_POST['email'].'"'; ?></p> <p>Desired User Name:<br><input type="text" name="user_name" <? if(!$row){echo 'value="'.$_POST['user_name'].'"';} ?></p> <p>Password:<br><input type="password" name="password" <? if($_POST['password']==$_POST['re_password']) {echo 'value="'.$_POST['password'].'"';} ?></p> <p>Re-Type Password:<br><input type="password" name="re_password" <? if($_POST['password']==$_POST['re_password']) {echo 'value="'.$_POST['re_password'].'"';} ?></p> <p>Memorable Word:<br><input type="text" name="memorable_word" <? if(!$row){echo 'value="'.$_POST['memorable_word'].'"';} ?></p> <p><input type="submit" name="submit" value="Sign Up"></p> </form> File name is registration.php. Confirm_join is below: # start the session session_start(); # check to see if the session on the previous page was created # if it was created, allow this page to run, otherwise # redirect the user to the join page. if($_SESSION['register_accept']!=1){ header("Location: registration.php"); exit; } # Connect to the database here # addslashes (Helps protect from SQL injection) and remove html $user = strip_tags(addslashes($_SESSION['user_name'])); $fname = strip_tags(addslashes($_SESSION['fname'])); $lname = strip_tags(addslashes($_SESSION['lname'])); $email = strip_tags(addslashes($_SESSION['email'])); $password = strip_tags(addslashes($_SESSION['password'])); $memorable_word = strip_tags(addslashes($_SESSION['memorable_word'])); # Insert into the database mysql_query("INSERT INTO ffl_managers(`userName`,`firstName`,`lastName`,`email`,`password`, `memorableWord`) VALUES('$user','$fname','$lname','$email','$password','$memorable_word')or die(mysql_error()); # If you would like to send an email, this would be the place to place it #redirect the user back to a page where they can login header("Location: login.php"); exit; Any thoughts? Aero. Quote Link to comment Share on other sites More sharing options...
adguru Posted June 15, 2008 Share Posted June 15, 2008 Its receiving the contents if the form is submitted, else it is displaying the form. Once submitted, the script is validating the entries. Be specific if you want to ask anything particular from the code. Quote Link to comment Share on other sites More sharing options...
aerouk Posted June 15, 2008 Author Share Posted June 15, 2008 Yes, that I know It seems to be WPE'ing though, and I can't understand why? Quote Link to comment Share on other sites More sharing options...
aerouk Posted June 15, 2008 Author Share Posted June 15, 2008 Hmmm still no luck. If anyone has any suggestions on whats going wrong with the above, please let me know. Thanks! Quote Link to comment Share on other sites More sharing options...
BrianM Posted June 15, 2008 Share Posted June 15, 2008 You still are not being specific upon what your wanting to achieve. What is the program not doing that you would like it to do? You have yet to specify, no one can help without you answering that question, aerouk. Quote Link to comment Share on other sites More sharing options...
aerouk Posted June 16, 2008 Author Share Posted June 16, 2008 Basically - It's not working, its WPE'ing. (White Page Error). It doesnt appear to take the input, validate it and then successfully post to my database. It WPE's upon clicking submit. Can anyone see any glaring errors in the code, or have any suggestions as to how I can fix it? Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted June 16, 2008 Share Posted June 16, 2008 use <?php ?> tags around your code, makes it more gentle on the eyes Quote Link to comment Share on other sites More sharing options...
aerouk Posted June 18, 2008 Author Share Posted June 18, 2008 The top one is there, just forgot to paste it in Anyone have any more thoughts? Quote Link to comment Share on other sites More sharing options...
revraz Posted June 18, 2008 Share Posted June 18, 2008 If you just get a white page error, try turning on display errors in your PHP.INI. I often wonder why people suppress errors when they try to troubleshoot. Quote Link to comment Share on other sites More sharing options...
revraz Posted June 18, 2008 Share Posted June 18, 2008 He means when you post it here, because the forum will color code your code if you use PHP tags within the CODE tags. The top one is there, just forgot to paste it in Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.