blink359 Posted April 27, 2009 Share Posted April 27, 2009 Notice: Undefined index: user in C:\wamp\www\register.php on line 107 Notice: Undefined index: pass in C:\wamp\www\register.php on line 108 Notice: Undefined index: pass2 in C:\wamp\www\register.php on line 109 Notice: Undefined index: flag in C:\wamp\www\register.php on line 110 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 {font-size: small} #apDiv1 { position:absolute; left:37px; top:210px; width:169px; height:30px; z-index:1; } body { background-color: #999999; } .cssnav { position: relative; font-family: arial, helvetica, sans-serif; background: url(images/overbtn.jpg) no-repeat; white-space: nowrap; display: block; width: 250px; height: 50px; margin: 0; padding: 0; } .cssnav a { display: block; color: #000000; font-size: 11px; width: 250px; height: 50px; display: block; float: left; color: black; text-decoration: none; } .cssnav img { width: 250px; height: 50px; border: 0 } * html a:hover { visibility:visible } .cssnav a:hover img { visibility:hidden } .cssnav span { position: absolute; left: 53px; top: 15px; margin: 0px; padding: 0px; cursor: pointer; width: 250px; } .style4 {font-size: 16px} --> </style> </head> <body> <center><table width="80%" border="1"> <tr> <th height="186" colspan="5" align="left" valign="top" scope="row"><img src="Images/logo2.jpg" width="944" height="215" /></th> </tr> <tr> <th width="25%" rowspan="2" align="left" valign="top" scope="row"><h2> <div class="cssnav"><a href="index.html" title="Home"><img src="images/downbtn.jpg" alt="Search Engine Optimization" /><span class="style4">Home</span></a></div> <div class="cssnav"><a href="register.php" title="Account creation"><img src="images/downbtn.jpg" alt="Search Engine Submission" /><span class="style4">Create Account</span></a></div> <div class="cssnav"><a href="phpbb3/index.php" title="Forums"><img src="images/downbtn.jpg" alt="Website Design" /><span class="style4">Forums</span></a></div> <div class="cssnav"><a href="vote.php" title="Vote"><img src="images/downbtn.jpg" alt="Website Promotion" /><span class="style4">Vote</span></a></div> <div class="cssnav"><a href="donate.html" title="Donate"><img src="images/downbtn.jpg" alt="Google" /><span class="style4">Donate</span></a></div> <br /> </h2> </th> <td colspan="3" rowspan="3" valign="top"> <center><form method="post" action=""> <p> <?php $dbhost = "localhost"; $dbuser = "root"; $dbpass = "ascent"; $dbname = "logon"; mysql_connect($dbhost, $dbuser, dbpass); mysql_select_db($dbname); $user = $_POST['user']; $pass = $_POST['pass']; $pass2 = $_POST['pass2']; $flag = $_POST['flag']; $success = true; $problemMessage = ""; if (isset($_POST['Submit'])) { if(!$user || !$pass || !$pass2) { $problemMessage .= "Please complete all required data <br />"; $success = false; } if(strlen($user) < 5) { $problemMessage .= "User must be more that 5 characters <br />"; $success = false; } if(strlen($user) > 20) { $problemMessage .= "Your username cannot be longer than 20 characters <br />"; $success = false; } if($pass != $pass2) { $problemMessage .= "Your passwords do not match <br />"; $success = false; } if(strlen($pass2) < 5) { $problemMessage .= "Your password must be more than 5 characters<br />"; $success = false; } if(strlen($pass2) > 20) { $problemMessage .= "Your password cannot be longer than 20 characters <br />"; $success = false; } if ($success) { echo "Valid New Account Entry<br />"; $result = mysql_query("INSERT INTO `accounts` VALUES ('', '$user', '$pass2', '', '', '0', '9', '', '', '$flag', 'enUS', '0', '0', null)") or die("Error: (" . mysql_errno() . ") " . mysql_error()); } } ?> <?php if ($success == false) { echo $problemMessage; } ?> Account Creation Page<br> Username: <input name="user" type="text"/> <br> Password: <input name="pass" type="text"/> <br> Repeat Password: <input name="pass2" tpye="text"/> <br /> Pre TBC <input type="radio" name="flag" value="0"> <br> TBC Enabled <input type="radio" name="flag" value="8"> <br> Wotlk Enabled <input type="radio" name="flag" value="24"> <br> <input name="Submit" type="submit" value="submit" /> </p> <imput name="reset" type="reset" value="reset" /> </form></center></td> <td width="22%" height="114" valign="top"><iframe src="phpbb3/login.php" scrolling="no" width="200" height="130"frameborder="1"></iframe> </td> </tr> <tr> <td height="129" valign="top"><p class="style1">Donate now to keep our server up</p> <p class="style1"><a href="http://www.paypal.com"><img src="Images/Paypal.png" width="207" height="87" /></a></p></td> </tr> <tr> <th height="224" valign="top" scope="row"><br /></th> <td><p> </p> </td> </tr> <tr> <th height="33" colspan="5" scope="row"> </th> </tr> </table> </center> </body> </html> Whats wrong? Link to comment https://forums.phpfreaks.com/topic/155797-undefined-varibles/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 27, 2009 Share Posted April 27, 2009 $_POST['user'], $_POST['pass'], $_POST['pass2'], and $_POST['flag'] don't exist at the time your code is being executed. You should put the lines of code that reference those variables inside of the form processing part of your code so that they are only evaluated after the point that if(isset($_POST['Submit'])) is true. Link to comment https://forums.phpfreaks.com/topic/155797-undefined-varibles/#findComment-820098 Share on other sites More sharing options...
blink359 Posted April 27, 2009 Author Share Posted April 27, 2009 Account Creation Page<br> Username: <input name="user" type="text"/> <br> Password: <input name="pass" type="text"/> <br> Repeat Password: <input name="pass2" tpye="text"/> <br /> Pre TBC <input type="radio" name="flag" value="0"> <br> TBC Enabled <input type="radio" name="flag" value="8"> <br> Wotlk Enabled <input type="radio" name="flag" value="24"> <br> <?php $user = $_POST['user']; $pass = $_POST['pass']; $pass2 = $_POST['pass2']; $flag = $_POST['flag']; ?> <input name="Submit" type="submit" value="submit" /> </p> <imput name="reset" type="reset" value="reset" /> So that? Link to comment https://forums.phpfreaks.com/topic/155797-undefined-varibles/#findComment-820103 Share on other sites More sharing options...
PFMaBiSmAd Posted April 27, 2009 Share Posted April 27, 2009 inside of the form processing part of your code That looks like it is inside of the form, not the form processing code. Link to comment https://forums.phpfreaks.com/topic/155797-undefined-varibles/#findComment-820104 Share on other sites More sharing options...
blink359 Posted April 27, 2009 Author Share Posted April 27, 2009 $success = true; $problemMessage = ""; if (isset($_POST['Submit'])) $user = $_POST['user']; $pass = $_POST['pass']; $pass2 = $_POST['pass2']; $flag = $_POST['flag']; { if(!$user || !$pass || !$pass2) { $problemMessage .= "Please complete all required data <br />"; $success = false; Link to comment https://forums.phpfreaks.com/topic/155797-undefined-varibles/#findComment-820105 Share on other sites More sharing options...
PFMaBiSmAd Posted April 27, 2009 Share Posted April 27, 2009 The { is part of the if() statement. Your lines of code would need to be after the { for them to be part of the form processing code. Link to comment https://forums.phpfreaks.com/topic/155797-undefined-varibles/#findComment-820115 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.