Ibshas25 Posted November 11, 2010 Share Posted November 11, 2010 errors shown below cant understand why its not defined???? Notice: Undefined index: username in /export/SOI-50/students/m2009/abhr428/web/WebIbs/userRegProcess.php on line 4 Notice: Undefined index: name in /export/SOI-50/students/m2009/abhr428/web/WebIbs/userRegProcess.php on line 5 Notice: Undefined index: surname in /export/SOI-50/students/m2009/abhr428/web/WebIbs/userRegProcess.php on line 6 Notice: Undefined index: password in /export/SOI-50/students/m2009/abhr428/web/WebIbs/userRegProcess.php on line 7 Notice: Undefined index: email in /export/SOI-50/students/m2009/abhr428/web/WebIbs/userRegProcess.php on line 8 Notice: Undefined index: contact in /export/SOI-50/students/m2009/abhr428/web/WebIbs/userRegProcess.php on line 9 save_failed <!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> <title>User Register</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="stylesheet" type="text/css" href="stylesheet1.css"/> <script type="text/javascript" src="jquery-1.4.3.js"></script> <script type="text/javascript" src="jquery.json-2.2.js"></script> <script type="text/javascript" src="forms.js"></script> <script type="text/javascript" src="saveUser1.js"></script> </head> <body> <center> <div style="width:280pt;height:350pt;border:5px solid #FFFFFF;"> <div id= "logo1"><img src="images/FINALlogo.jpg" width="60" height="50" /></div> <form id="user_details" action="userRegProcess.php" method="post"> <h1>User Registration form</h1> <legend> Enter Detail Below</legend> <br /> <table> <fieldset> <tr><td width="241"><label for="name">Username</label> <tr><td><input type="text" name="username"/></tr></td> <tr><td><label for="name">Name </label> <tr><td><input type="text" name="name"/></tr></td> <tr><td><label for="name">Surname</label> <tr><td><input type="text" name="surname" width="200"/></tr></td> <tr><td><label for="name">Enter password</label> <tr><td><input type="text" name="password" width="200"/></tr></td> <tr><td><label for="name">Email Address</label> <tr><td><input type="text" name="email" width="250"/></tr></td> <tr><td><label for="name">Contact</label> <tr><td><input type="text" name="contact" width="250"/></tr></td> <tr><td><button type="button" onclick="processUserDetails();">Submit</button></td></tr> <div style="clear:both;"></div> </fieldset> </table> </form> </div> <?php // Retrieve form data $username = $_POST['username']; $name = $_POST['name']; $surname = $_POST['surname']; $password = $_POST['password']; $email = $_POST['email']; $contact = $_POST['contact']; if (!$username || !$name || !$surname || !$Password || !email || !contact) { echo "save_failed"; return; } $db = array( 'host' => 'vega.soi.city.ac.uk', 'login' => 'abhr428', 'password' => '040010722', 'database' => 'abhr428', ); $link = @mysql_connect($db['host'], $db['login'], $db['password']); if (!$link) { echo "save_failed"; return; } mysql_select_db($db['database']); // Clean variables before performing insert $clean_username = mysql_real_escape_string($username); $clean_name = mysql_real_escape_string($name); $clean_surname = mysql_real_escape_string($surname); $clean_password = mysql_real_escape_string($password); $clean_email = mysql_real_escape_string($email); $clean_contact = mysql_real_escape_string($contact); // Perform insert $sql = "INSERT INTO users (usr_id, usr_name, usr_surname, usr_password, usr_email, usr_contact) VALUES ('{$clean_username}', {$clean_name}, '{$clean_surname}', '{$clean_password}', '{clean_email}', '{clean_contact}')"; if (@mysql_query($sql, $link)) { echo "success"; @mysql_close($link); return; } else { echo "save_failed"; @mysql_close($link); return; } ?> Link to comment https://forums.phpfreaks.com/topic/218375-notice-undefined-index-username-in/ Share on other sites More sharing options...
JasonLewis Posted November 11, 2010 Share Posted November 11, 2010 That happens after submitting the form? Try a var_dump() or print_r() on the $_POST variable. See what it outputs. Link to comment https://forums.phpfreaks.com/topic/218375-notice-undefined-index-username-in/#findComment-1133008 Share on other sites More sharing options...
Ibshas25 Posted November 11, 2010 Author Share Posted November 11, 2010 The form page works with the validation and doestn gve any errors when submitting, but the server is throwing back these errors hence why its probably not loading the data in the databse... not sure how to go about what u just mentioned. Link to comment https://forums.phpfreaks.com/topic/218375-notice-undefined-index-username-in/#findComment-1133098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.