runnerjp Posted November 17, 2006 Share Posted November 17, 2006 hey guys im making like a myspace siteran into a problemok this code should create the users (registration) but it appears to just send me to a blank page every time sum 1 hits submit...i dnt under stand why (this is my 1st time making a script like this) can any 1 help me out??[code]<?if (empty($_POST)) { ?><p> </p><form method="POST"><table align="center" cellpadding="4" cellspacing="0" width="60%"> <form action="doreg.php" method="POST"><table cellspacing="0" width="100%" bordercolordark="white" bordercolorlight="black" cellpadding="4"> <tr> <td width="985" colspan="3"> <p><b>Register for your own Profile Page!</b><br>S<i>tep 1: </i>create a user account</p> <p> </p> </td> </tr> <tr> <td width="242" valign="top" bgcolor="#F7F7F7"> <p>User Name:</p> </td> <td width="250" valign="top" bgcolor="#F7F7F7"> <p><input type="text" name="login" maxlength="16" size="12"></p> </td> <td width="477" valign="top" bgcolor="#F7F7F7"> <p><span class="help">This is the nickname people will see. You may use letters and/or numbers, but no spaces or other characters.</span></p> </td> </tr> <tr> <td width="242" valign="top"> <p>Password:</p> </td> <td width="250" valign="top"> <p><input type="password" name="pass1" maxlength="16" size="16"></p> </td> <td width="477" valign="top"> <p><span class="help">Choose a password. You may use letters and/or numbers. Your password must be 3-16 characters.</span></p> </td> </tr> <tr> <td width="242" valign="top" bgcolor="#F7F7F7"> <p>Verify Password:</p> </td> <td width="250" valign="top" bgcolor="#F7F7F7"> <p><input type="password" name="pass2" maxlength="16" size="16"></p> </td> <td width="477" valign="top" bgcolor="#F7F7F7"> <p><span class="help">Verify your password.</span></p> </td> </tr> <tr> <td width="242" valign="top"> <p>Email Address:</p> </td> <td width="250" valign="top"> <p><input type="text" name="email" maxlength="100" size="20"></p> </td> <td width="477" valign="top"> <p><span class="help">Enter your email address. </span><u><span class="help">It is not displayed to visitors</span></u><span class="help">, but is used in case you forget your password.</span></p> </td> </tr> <tr> <td width="242" valign="top" bgcolor="#F7F7F7"> <p>First name:</p> </td> <td width="250" valign="top" bgcolor="#F7F7F7"> <p><input type="text" name="firstname" maxlength="24" size="20"></p> </td> <td width="477" valign="middle" rowspan="2" bgcolor="#F7F7F7"> <p><span class="help">Your name is not displayed to visitors, but is used by the system to greet you. Visitors may search by your real name.</span></p> </td> </tr> <tr> <td width="242" valign="top" bgcolor="#F7F7F7"> <p>Last name:</p> </td> <td width="250" valign="top" bgcolor="#F7F7F7"> <p><input type="text" name="lastname" maxlength="24" size="20"></p> </td> </tr> <tr> <td width="242" valign="top"> <p>Zipcode:</p> </td> <td width="250" valign="top"> <p><input type="text" name="zipcode" maxlength="5" size="5"></p> </td> <td width="477" valign="top"> <p><span class="help">Your zipcode is used to search by location.</span></p> </td> </tr> <tr> <td width="985" valign="top" colspan="3"> <p align="center"> <input type="submit" name="submit" value="Register"></p> </td> </tr></table></form><p> </p><? }?>[/code]have i not linked it to anouther page or summats loli find it funny how the mistake can be easly seen by sum 1 else but not u hahacheers guys Link to comment https://forums.phpfreaks.com/topic/27626-whats-wrong-with-this-code/ Share on other sites More sharing options...
chiprivers Posted November 17, 2006 Share Posted November 17, 2006 Have you checked the script on the page it is directed to? If there is a fault in your script it may display a blank page. Link to comment https://forums.phpfreaks.com/topic/27626-whats-wrong-with-this-code/#findComment-126346 Share on other sites More sharing options...
craygo Posted November 17, 2006 Share Posted November 17, 2006 Well first you are not telling the form to go anywhere. You need to send it to a page to be executed[code]<form method="POST" action="somepage.php">[/code]Then on somepage.php you write your code to enter into database or whatever you want to do.Leaving it blank will go to the current page. In that case it is doing what your script says. You have an "if(empty($_POST))" but you don't have an else at the end for it to do something else if it is set. add this to the end[code]<p> </p><? } else {echo "Registration sent";}?>[/code]SeeRay Link to comment https://forums.phpfreaks.com/topic/27626-whats-wrong-with-this-code/#findComment-126349 Share on other sites More sharing options...
runnerjp Posted November 17, 2006 Author Share Posted November 17, 2006 well its directed to right 1 i think.... what i will do is post them all here then you can see full thing lolhere is do reg...this basicly brings every thing together yer[code]<?// File ID: doreg.php (processes registration form)include("require/config.php");require("require/authentication.php");$auth=authenticate($login, $password); //authentication$content="$incpath/doreg.inc.php";if ($auth[error]) {$menu="$incpath/menu_u.inc.php";} else {$menu="$incpath/menu_v.inc.php";}$page_title="Register";include("$incpath/header.inc.php");include("$incpath/body.inc.php");include("$incpath/right.inc.php");include("$incpath/footer.inc.php");?>[/code]so 1st bit leads to connection to oviusly get my user details yer so dnt need to post that here then authentication[code]<?function authenticate ($login, $password) {global $db_name, $tbl_user, $incpath;include("$incpath/error.php");$valid = mysql_fetch_array(mysql_db_query($db_name, "SELECT * FROM $tbl_user WHERE login='$login'"));if ($login) {if ($password == crypt($valid[password], $login)) {if ($valid[active] == "enable") {$result=$valid;} else {$result[error]=$strError700;}} else {$result[error]=$strError800;}} else {$result[error]=$strError200;}return $result;}?>[/code]then their is my doreg.inc.php[code]<?$login_length = strlen("$login");$pass_length = strlen("$pass1");$table_name = "$tbl_user";$connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect.");$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");$check = "SELECT * FROM $table_name WHERE login = \"$login\"";$check_r = @mysql_query($check,$connection) or die("Couldn't execute login query.");$num=mysql_num_rows($check_r);if($num > 0){echo "<center>The Username <b>$login</b> is already taken. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}if(empty($login)) {echo "<center>You didn't enter a User Name. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}elseif($login_length < 3) {echo "<center>Your User Name must be at least 3 characters. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}elseif(empty($pass1)) {echo "<center>You didn't enter a password. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}elseif($pass_length < 3) {echo "<center>Your password must be at least 3 characters. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}elseif(empty($pass2)) {echo "<center>You didn't verify your password. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}elseif(empty($email)) {echo "<center>You didn't enter an email address. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}elseif(empty($firstname)) {echo "<center>You didn't enter your first name. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}elseif(empty($lastname)) {echo "<center>You didn't enter your last name. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}elseif(empty($zipcode)) {echo "<center>You didn't enter your zipcode. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}elseif(ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,3})$", $email)) {$okmail="1";}if($okmail != "1") {echo "<center>Your email address is not properly formatted. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}if (ereg("^[_a-zA-Z0-9-]+$",$login)) {$oklogin="1";}if($oklogin != "1") {echo "<center>Your User Name can contain only letters and numbers. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}if (ereg("^[_a-zA-Z-]+$",$firstname)) {$okfirst="1";}if($okfirst != "1") {echo "<center>Your first name can contain only letters. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}if (ereg("^[_a-zA-Z-]+$",$lastname)) {$oklast="1";}if($oklast != "1") {echo "<center>Your last name can contain only letters. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}if($pass1 != $pass2) {echo "<center>Your passwords do not match. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}if (ereg("^[0-9]+$",$zipcode)) {$okzip="1";}if($okzip != "1") {echo "<center>Your zipcode can contain only numbers. Please try again.<br><br><input type=button value=\"Back\" onClick=\"history.go(-1)\"></center>";include("$incpath/right.inc.php");include("$incpath/footer.inc.php");exit;}$table_name = "$tbl_user";$connection = @mysql_connect("$db_host", "$db_user", "$db_pass") or die("Couldn't connect.");$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");$sql = "INSERT INTO $table_name(login, password, email, firstname, lastname, zipcode)VALUES(\"$login\", \"$pass1\", \"$email\", \"$firstname\", \"$lastname\", \"$zipcode\")";$result = @mysql_query($sql,$connection) or die("Couldn't execute query.");include("$incpath/welcome_msg.inc.php");include("$incpath/reg_success.inc.php");?>[/code]this should creat it all ^^^ am i correct??and here is the 1st page the person views to start regestering[code]<?if (empty($_POST)) { ?><p> </p><form method="POST"><table align="center" cellpadding="4" cellspacing="0" width="60%"> <form action="doreg.php" method="POST"><table cellspacing="0" width="100%" bordercolordark="white" bordercolorlight="black" cellpadding="4"> <tr> <td width="985" colspan="3"> <p><b>Register for your own Profile Page!</b><br>S<i>tep 1: </i>create a user account</p> <p> </p> </td> </tr> <tr> <td width="242" valign="top" bgcolor="#F7F7F7"> <p>User Name:</p> </td> <td width="250" valign="top" bgcolor="#F7F7F7"> <p><input type="text" name="login" maxlength="16" size="12"></p> </td> <td width="477" valign="top" bgcolor="#F7F7F7"> <p><span class="help">This is the nickname people will see. You may use letters and/or numbers, but no spaces or other characters.</span></p> </td> </tr> <tr> <td width="242" valign="top"> <p>Password:</p> </td> <td width="250" valign="top"> <p><input type="password" name="pass1" maxlength="16" size="16"></p> </td> <td width="477" valign="top"> <p><span class="help">Choose a password. You may use letters and/or numbers. Your password must be 3-16 characters.</span></p> </td> </tr> <tr> <td width="242" valign="top" bgcolor="#F7F7F7"> <p>Verify Password:</p> </td> <td width="250" valign="top" bgcolor="#F7F7F7"> <p><input type="password" name="pass2" maxlength="16" size="16"></p> </td> <td width="477" valign="top" bgcolor="#F7F7F7"> <p><span class="help">Verify your password.</span></p> </td> </tr> <tr> <td width="242" valign="top"> <p>Email Address:</p> </td> <td width="250" valign="top"> <p><input type="text" name="email" maxlength="100" size="20"></p> </td> <td width="477" valign="top"> <p><span class="help">Enter your email address. </span><u><span class="help">It is not displayed to visitors</span></u><span class="help">, but is used in case you forget your password.</span></p> </td> </tr> <tr> <td width="242" valign="top" bgcolor="#F7F7F7"> <p>First name:</p> </td> <td width="250" valign="top" bgcolor="#F7F7F7"> <p><input type="text" name="firstname" maxlength="24" size="20"></p> </td> <td width="477" valign="middle" rowspan="2" bgcolor="#F7F7F7"> <p><span class="help">Your name is not displayed to visitors, but is used by the system to greet you. Visitors may search by your real name.</span></p> </td> </tr> <tr> <td width="242" valign="top" bgcolor="#F7F7F7"> <p>Last name:</p> </td> <td width="250" valign="top" bgcolor="#F7F7F7"> <p><input type="text" name="lastname" maxlength="24" size="20"></p> </td> </tr> <tr> <td width="242" valign="top"> <p>Zipcode:</p> </td> <td width="250" valign="top"> <p><input type="text" name="zipcode" maxlength="5" size="5"></p> </td> <td width="477" valign="top"> <p><span class="help">Your zipcode is used to search by location.</span></p> </td> </tr> <tr> <td width="985" valign="top" colspan="3"> <p align="center"> <input type="submit" name="submit" value="Register"></p> </td> </tr></table></form><p> </p><? }?>[/code]thats everything :D:D so wats going wrong...must b summats rlly simple Link to comment https://forums.phpfreaks.com/topic/27626-whats-wrong-with-this-code/#findComment-126350 Share on other sites More sharing options...
runnerjp Posted November 17, 2006 Author Share Posted November 17, 2006 yer but craygo its not actually regestering it lol shouldent [quote]form action="doreg.php" method="POST">[/quote] send it to the right page dore.php and from their should send the data to my datbase and send the user to a webpage telling them its corrated (regsucess.inc.php) Link to comment https://forums.phpfreaks.com/topic/27626-whats-wrong-with-this-code/#findComment-126351 Share on other sites More sharing options...
runnerjp Posted November 17, 2006 Author Share Posted November 17, 2006 ahhh w8 i got what u ment and it worked :D:D thanks loads craygo Link to comment https://forums.phpfreaks.com/topic/27626-whats-wrong-with-this-code/#findComment-126355 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.