Dirt_Diver Posted August 22, 2008 Share Posted August 22, 2008 I'm trying to get my page to display some text after a user registers with my site but it's not working... Can someone please debug this for me??? <?php include("my_connect_file.php"); //This code runs if the form has been submitted if (isset($_POST['submit'])) { //This makes sure they did not leave any fields blank if (!$_POST['first_name'] || !$_POST['last_name'] || !$_POST['email'] || !$_POST['city'] || !$_POST['state'] || !$_POST['zip'] || !$_POST['gender'] || !$_POST['username'] || !$_POST['pass'] || !$_POST['pass2']) { die('Whoops!!! Did you forget to fill in one of the fields? Please go back and try again.'); } // checks if the username is in use $usercheck = $_POST['username']; $check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'") or die(mysql_error()); $check2 = mysql_num_rows($check) or die(mysql_error()); //if the name exists it gives an error if ($check2 != 0) { die('Sorry, the username <strong><u>'.$_POST['username'].'</u></stong> has already been taken. Please choose another username.'); } // this makes sure both passwords entered match if ($_POST['pass'] != $_POST['pass2']) { die('Whoops!!! I think you made a mistake. We need your passwords to match. Please go back and try again.'); } // check e-mail format if (!preg_match("/.*@.*..*/", $_POST['email']) || preg_match("/(<|>)/", $_POST['email'])) { die('Invalid e-mail address.'); } // no HTML tags in username, website, address, password $_POST['username'] = strip_tags($_POST['username']); $_POST['pass'] = strip_tags($_POST['pass']); $_POST['website'] = strip_tags($_POST['website']); $_POST['address'] = strip_tags($_POST['address']); if ($_POST['show_email'] != 0 & $_POST['show_email'] != 1) { die('Nope'); } if ($_POST['website'] != '' & !preg_match("/^(http|ftp):///", $_POST['website'])) { $_POST['website'] = 'http://'.$_POST['website']; } // here we encrypt the password and add slashes if needed // now we insert it into the database $_POST['pass'] = md5($_POST['pass']); if (!get_magic_quotes_gpc()) { $_POST['pass'] = addslashes($_POST['pass']); $_POST['email'] = addslashes($_POST['email']); $_POST['website'] = addslashes($_POST['website']); $_POST['location'] = addslashes($_POST['location']); } $regdate = date('m d, Y'); $insert = "INSERT INTO users ( first_name, last_name, email, address, city, state, zip, country, regdate, gender, website, show_email, username, password, last_login) VALUES ( '".$_POST['first_name']."', '".$_POST['last_name']."', '".$_POST['email']."', '".$_POST['address']."', '".$_POST['city']."', '".$_POST['state']."', '".$_POST['zip']."', '".$_POST['country']."', '$regdate', '".$_POST['gender']."', '".$_POST['website']."', '".$_POST['show_email']."', '".$_POST['username']."', '".$_POST['pass']."', 'Never')"; $add_member = mysql_query($insert); ?> <?php *****************THIS IS WHAT SHOULD COME UP AFTER THE USER CREATES THEIR USERNAME************ SUCCESS Congratulations {USERNAME} your sign up was a success, you may now return to the home page and [login] <br /><style type="text/css"><br /><!--<br />.style3 {font-weight: bold}<br />.style4 {font-weight: bold}<br />--><br /></style><br /><br /><center><h1>SUCCESS</h1></center><br><br><br><br><br /><center>Congratulations <u><strong><?php <br />print $_POST['username'];<br />?></u></strong> your sign up was a success, you may now return to the home page and <a href="index.php">[login]</a></center> <?php } else { ?> <br /><br /><form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><br /> <table width="530" border="0" cellspacing="2" cellpadding="0"><br /> <tr><br /> <td height="50" colspan="2"><table width="80%" border="0" align="center" cellpadding="0" cellspacing="0"><br /> <tr><br /> <td><p>Thanks for thinking about registering with us. Sign up is fast and easy. all you need to do is fill in the spaces below. </p><br /> <p align="center"> <strong>* Required fields </strong></p></td><br /> </tr><br /> </table> </td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3">*First Name:</div></td><br /> <td width="224"><input id="first_name" name="first_name" type="text" size="25" value="" maxlength="50"></td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3">*Last Name:</div></td><br /> <td><input id="last_name" name="last_name" type="text" size="25" value="" maxlength="50"></td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3">*Email Address:</div></td><br /> <td><input id="email" name="email" type="text" size="25" value="" maxlength="50"> </td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3">Address</div></td><br /> <td><input id="address" name="address" type="text" size="25" value="" maxlength="40"></td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3">*City:</div></td><br /> <td><input id="city" name="city" type="text" size="25" value="" maxlength="25"></td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3"><strong><br /> <label for="state">*State:</label><br /> </strong></div></td><br /> <td><input id="state" name="state" type="text" size="25" value="" maxlength="20"></td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3"><strong><br /> <label for="zip">Zip Code: </label><br /> </strong></div></td><br /> <td><input id="zip" name="zip" type="text" size="25" value="" maxlength="10"></td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3"><strong><br /> <label for="country">*Country:</label><br /> </strong></div></td><br /> <td><input id="country" name="country" type="text" size="25" value="" maxlength="25"></td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3"><strong><br /> <label for="gender">*Gender:</label><br /> </strong></div></td><br /> <td><select name="gender" id="gender"><br /> <option selected>Please Choose</option><br /> <option value="M">Male</option><br /> <option value="F">Female</option><br /> </select></td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3"><strong><br /> <label for="website">Website Address: </label><br /> </strong></div></td><br /> <td><input id="website" name="website" type="text" size="25" value="http://" maxlength="100"> </td><br /> </tr><br /> <tr><br /> <td><div align="right" class="style3"><strong><br /> <label for="show_email"> Show Email?:</label><br /> </strong></div></td><br /> <td><select name="show_email" id="show_email"><br /> <option value="1" selected>Yes</option><br /> <option value="0">No</option><br /> </select></td><br /> </tr><br /> <tr><br /> <td height="24"> </td><br /> <td> </td><br /> </tr><br /> <tr><br /> <td> </td><br /> <td> </td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3"><strong><label for="username"> *Username:</label><br /> </strong></div></td><br /> <td><input id="username" name="username" type="text" size="25" value="" maxlength="20"></td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3"><strong><br /> <label for="password">*New Password:</label><br /> </strong></div></td><br /> <td><input id="pass" name="pass" type="password" size="25" value="" maxlength="25"></td><br /> </tr><br /> <tr><br /> <td width = "300"><div align="right" class="style3"><strong><br /> <label for="confirm password">*Confirm Password: </label><br /> </strong></div></td><br /> <td><input id="pass2" name="pass2" type="password" size="25" value="" maxlength="20"></td><br /> </tr><br /> <tr><br /> <td width="300"></td><br /> <td><input name="submit" type="submit" id="submit" value="Sign Up"></td><br /> </tr><br /></table><br /></form> <?php } ?> EDIT by zanus: Why would you put small things in code tags but nearly an entire page outside of them? Quote Link to comment Share on other sites More sharing options...
btherl Posted August 22, 2008 Share Posted August 22, 2008 I'm trying to get my page to display some text after a user registers with my site but it's not working... In what way does it not work? Is the user registered but no text is displayed? Quote Link to comment Share on other sites More sharing options...
Dirt_Diver Posted August 22, 2008 Author Share Posted August 22, 2008 No the user is not registered. the page is here; http://www.treasureshackonline.com/add.php When the user goes to create a page they fill in the form and click on submit. Once the data was entered into the database the message would come back with SUCCESS Congratulations {THE USERS NEW NAME} your sign up was a success, you may now return to the home page and [login] Now after you fill in the form and click submit nothing is happening. The page goes blank and the data is not posting to the DB. All and any help is much appreciated. ** Not sure what happened with the code above but here is a copy of the PHP code. Save it as a txt and change it to PHP after download or save it as a php page. http://www.treasureshackonline.com/register_page.txt Quote Link to comment Share on other sites More sharing options...
Kryllster Posted August 22, 2008 Share Posted August 22, 2008 Well I have a login success and creation page and I use this: // Redirect if it works header("Location:mainview.php?show=yourpagehere"); } The one above is for the login screen here is one for my creation page: // Direct on Creation Success echo "<META HTTP-EQUIV=\"Refresh\"CONTENT=\"0; URL=create_success.php\">"; Not sure if this will help just thought I would pass it on!! Good Luck, Quote Link to comment Share on other sites More sharing options...
btherl Posted August 25, 2008 Share Posted August 25, 2008 Dirt_diver, can you add this line to the top of your script: ini_set('display_errors', 1); That may give you some useful information. 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.