SirChick Posted July 31, 2007 Share Posted July 31, 2007 Basically when the page is loaded this code just runs and goes straight to the redirect page at the bottom of the php. It doesn't load the html at all :S Should the html be saved in a html and then the php be saved in a php and then have the html call the php ? But if that was the case how do you do that so that it only calls the php upon the register button being pressed.... This is exactly how i have written my php file. Should i re-arrange the php tags and html tags or something? I'm not entirely sure..would like some thoughts here.. sorry its alot of code to read! lol <?php if (isset($_POST['RegistrationSubmission'])) { $TermsOfService = ($_POST['TermsOfService']); $Username = ($_Post['Username']); $Password = ($_POST['Password']); $Password2 = ($_POST['Password2']); $Email = ($_POST['EmailRegistration']); $Country = ($_POST['CountryChoice']); $_SERVER = $_POST['REMOTE_ADDR']; mysql_connect("localhost", "root", "private") or die (mysql_error()); mysql_select_db("databasename") or die (mysql_error()); $chkUSERNAME = mysql_query("SELECT * FROM `userregistration` WHERE `Username` = '".$_POST['Username']."'"); $getUSERNAME = mysql_fetch_object($chkUSERNAME); if($_POST['Username'] == $getUSR->Username) { die('Username already registered, please choose a different username!'); } If ($Password == $Password2) { mysql_connect("localhost", "root", "private") or die (mysql_error()); mysql_select_db("databasename") or die (mysql_error()); $query = "INSERT INTO `userregistration` (Username,Email,Gender,Password) Values ('$Username','$Email', '$Gender', '$Password')"; echo $query; mysql_query($query) or die(mysql_error()); } else if ($Password != $Password2) { echo "passwords did not match"; if ($TermsOfService == "off") { echo "You must agree to the terms of service before registering!"; } } } header("Location: success.php"); HTML <html> <head> <title>Register Page</title> <script language="JavaScript" type="text/javascript"> <!-- function ValidateForm1(theForm) { var strFilter = /^[A-Za-zƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ]*$/; var chkVal = theForm.Editbox2.value; if (!strFilter.test(chkVal)) { alert("Username must be letters only, minimum of 3 and maximum of 11 characters."); theForm.Editbox2.focus(); return false; } if (theForm.Editbox2.value == "") { alert("Username must be letters only, minimum of 3 and maximum of 11 characters."); theForm.Editbox2.focus(); return false; } if (theForm.Editbox2.value.length < 3) { alert("Username must be letters only, minimum of 3 and maximum of 11 characters."); theForm.Editbox2.focus(); return false; } if (theForm.Editbox2.value.length > 11) { alert("Username must be letters only, minimum of 3 and maximum of 11 characters."); theForm.Editbox2.focus(); return false; } var strFilter = /^[A-Za-zƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0-9-]*$/; var chkVal = theForm.Editbox1.value; if (!strFilter.test(chkVal)) { alert("Passwords must be minimum 5 to maximum 15 characters long!"); theForm.Editbox1.focus(); return false; } if (theForm.Editbox1.value == "") { alert("Passwords must be minimum 5 to maximum 15 characters long!"); theForm.Editbox1.focus(); return false; } if (theForm.Editbox1.value.length < 5) { alert("Passwords must be minimum 5 to maximum 15 characters long!"); theForm.Editbox1.focus(); return false; } if (theForm.Editbox1.value.length > 15) { alert("Passwords must be minimum 5 to maximum 15 characters long!"); theForm.Editbox1.focus(); return false; } var strFilter = /^[A-Za-zƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0-9-]*$/; var chkVal = theForm.Editbox4.value; if (!strFilter.test(chkVal)) { alert("Passwords must be minimum 5 to maximum 15 characters long!"); theForm.Editbox4.focus(); return false; } if (theForm.Editbox4.value == "") { alert("Passwords must be minimum 5 to maximum 15 characters long!"); theForm.Editbox4.focus(); return false; } var strValue = theForm.Editbox3.value; var strFilter = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i; if (!strFilter.test(strValue)) { alert("Must be a valid email address!"); return false; } if (theForm.Editbox3.value == "") { alert("Must be a valid email address!"); theForm.Editbox3.focus(); return false; } if (theForm.Editbox3.value.length < 1) { alert("Must be a valid email address!"); theForm.Editbox3.focus(); return false; } if (theForm.Combobox1.selectedIndex < 0) { alert("Please select one of the \"Country Choice\" options."); theForm.Combobox1.focus(); return false; } if (theForm.Combobox1.selectedIndex == 0) { alert("The first \"Country Choice\" option is not a valid selection. Please choose one of the other options."); theForm.Combobox1.focus(); return false; } return true; } //--> </script> </head> <body bgcolor="#466B98" text="#000000" style="scrollbar-face-color:#C8E8F8;scrollbar-arrow-color:#000000;scrollbar-3dlight-color:#C8E8F8;scrollbar-darkshadow-color:#404040;scrollbar-highlight-color:#E8F4FF;scrollbar-shadow-color:#40B0E8;scrollbar-track-color:#E8F4FF;"> <img src="Banner1_05_37.jpg" id="Image1" alt="" align="top" border="3" width="994" height="94" style="position:absolute;left:0px;top:0px;width:994px;height:94px;border-color:#FFFFFF;z-index:20"> <div id="bv_" style="position:absolute;left:78px;top:457px;width:779px;height:319px;z-index:21" align="left"> <form name="registration" method="POST" action="" enctype="multipart/form-data" id="Form1" onsubmit="return ValidateForm1(this)"> <input type="text" id="Editbox2" style="position:absolute;left:193px;top:44px;width:144px;font-family:Courier;font-size:19px;z-index:0" size="16" name="Username" value="" maxlength="11"> <input type="password" id="Editbox1" style="position:absolute;left:194px;top:85px;width:144px;font-family:Courier;font-size:19px;z-index:1" size="16" name="Password" value="" maxlength="15"> <input type="password" id="Editbox4" style="position:absolute;left:193px;top:123px;width:144px;font-family:Courier;font-size:19px;z-index:2" size="16" name="Password2" value="" maxlength="15"> <div id="bv_Text1" style="position:absolute;left:31px;top:49px;width:150px;height:16px;z-index:3" align="left"> <font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Enter Your Username : </b></font></div> <div id="bv_Text2" style="position:absolute;left:34px;top:91px;width:150px;height:16px;z-index:4" align="left"> <font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Enter Your Password :</b></font></div> <div id="bv_Text3" style="position:absolute;left:14px;top:129px;width:170px;height:16px;z-index:5" align="left"> <font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Re-Enter Your Password :</b></font></div> <input type="text" id="Editbox3" style="position:absolute;left:194px;top:162px;width:144px;font-family:Courier;font-size:19px;z-index:6" size="16" name="EmailRegistration" value=""> <div id="bv_Text4" style="position:absolute;left:70px;top:163px;width:112px;height:16px;z-index:7" align="left"> <font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Email Addresss :</b></font></div> <hr size="60" width="168" id="Line2" style="position:absolute;left:379px;top:42px;width:168px;height:60px;z-index:8"> <div id="bv_Text5" style="position:absolute;left:377px;top:52px;width:73px;height:16px;z-index:9" align="center"> <font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Gender :</b></font></div> <input type="radio" id="RadioButton2"" name="Gender" value="Male" checked style="position:absolute;left:447px;top:51px;z-index:10"> <div id="bv_Text6" style="position:absolute;left:471px;top:53px;width:61px;height:16px;z-index:11" align="center"> <font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Male</b></font></div> <input type="radio" id="RadioButton1"" name="Gender" value="Female" style="position:absolute;left:447px;top:79px;z-index:12"> <div id="bv_Text7" style="position:absolute;left:471px;top:83px;width:66px;height:16px;z-index:13" align="center"> <font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Female</b></font></div> <hr size="56" width="237" id="Line1" style="position:absolute;left:379px;top:128px;width:237px;height:56px;z-index:14"> <div id="bv_Text9" style="position:absolute;left:395px;top:139px;width:170px;height:32px;z-index:15" align="left"> <font style="font-size:13px" color="#FFFFFF" face="Arial"><b>I Agree to Terms Of Service:</b></font></div> <input type="checkbox" id="Checkbox2"" name="TermsOfService" value="On" style="position:absolute;left:474px;top:153px;z-index:16"> <input type="submit" id="Button2"" name="RegistrationSubmission" value="Register!" style="position:absolute;left:679px;top:90px;width:75px;height:24px;z-index:17"> <div id="bv_Text11" style="position:absolute;left:29px;top:206px;width:150px;height:16px;z-index:18" align="center"> <font style="font-size:13px" color="#FFFFFF" face="Arial"><b>Game Country Choice:</b></font></div> <select name="CountryChoice" size="1" id="Combobox1" style="position:absolute;left:192px;top:203px;width:150px;font-family:MS Shell Dlg;z-index:19"> <option></option> <option value="Uk">United Kingdom</option> </select> </form> </div> <div id="bv_" style="position:absolute;left:278px;top:814px;width:329px;height:100px;z-index:22" align="center"> <font style="font-size:13px" color="#FFFFFF" face="Arial"><b>By clicking the button above you are agreeing to <br> Terms Of Service. <br> </font><font style="font-size:15px" color="#FFFFFF" face="Arial">If you get offended easily, please do not join.<br> <br> </b></font></div> <div id="bv_" style="position:absolute;left:317px;top:147px;width:345px;height:284px;z-index:23" align="left"> <img src="bv01023.gif" id="Shape2" align="top" alt="" border="0" width="345" height="284"></div> <div id="bv_" style="position:absolute;left:318px;top:165px;width:337px;height:44px;z-index:24" align="center"> <font style="font-size:19px" color="#000000" face="Arial"><b><u>Please read the rules of the game here before you contine!</u></b></font></div> <div id="bv_" style="position:absolute;left:352px;top:229px;width:256px;height:194px;z-index:25" align="left"> <table width="100%" border="0" cellpadding="0" cellspacing="2" id="BulletedList2"> <tr> <td align="left" valign="top" width="72" height="50"><font style="font-size:13px;" color="#000000" face="Wingdings">¡</font></td> <td align="left" valign="top" width="178" height="50"><font style="font-size:13px" color="#000000" face="Arial">Multiple Accounts is not allowed and will result in a permanent ban.</font></td> </tr> <tr> <td align="left" valign="top" width="72" height="50"><font style="font-size:13px;" color="#000000" face="Wingdings">¡</font></td> <td align="left" valign="top" width="178" height="50"><font style="font-size:13px" color="#000000" face="Arial">Users must be over 13. If you are not over 13 ask your parents for permission first.</font></td> </tr> <tr> <td align="left" valign="top" width="72" height="34"><font style="font-size:13px;" color="#000000" face="Wingdings">¡</font></td> <td align="left" valign="top" width="178" height="34"><font style="font-size:13px" color="#000000" face="Arial">Respect other players and they will respect you!</font></td> </tr> <tr> <td align="left" valign="top" width="72" height="50"><font style="font-size:13px;" color="#000000" face="Wingdings">¡</font></td> <td align="left" valign="top" width="178" height="50"><font style="font-size:13px" color="#000000" face="Arial">Spam & advertisements of other sites not allowed and will result a permanent ban.</font></td> </tr> </table></div> <div id="bv_" style="position:absolute;left:134px;top:232px;width:150px;height:144px;z-index:26" align="center"> <font style="font-size:13px" color="#FFFFFF" face="Arial">Please make sure you have read the rules to the right hand side.<br> <br> <br> Also make sure you agree to the:<br> <br> <b><u>Terms Of Service</u></b></font></div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/62666-site-just-skips-my-code/ Share on other sites More sharing options...
wildteen88 Posted July 31, 2007 Share Posted July 31, 2007 On line 35 you have this: header("Location: success.php"); That header statement is on its own and is not within any condition. So as soon as PHP gets to that line no matter whats going on in your script it is always going to redirect to success.php What you will want to do is place it within an if when a certain condition is met. Quote Link to comment https://forums.phpfreaks.com/topic/62666-site-just-skips-my-code/#findComment-311889 Share on other sites More sharing options...
SirChick Posted July 31, 2007 Author Share Posted July 31, 2007 ok i think i have an idea on that one will try it out thankyou! Quote Link to comment https://forums.phpfreaks.com/topic/62666-site-just-skips-my-code/#findComment-311890 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.