Jump to content

undifined index


newbie12345

Recommended Posts

hey im getting ah little problem when trying to send information to the database

 

these are the error im getting

 

Notice: Undefined index: u_name in C:\wamp\www\music website\register.php on line 104

 

Notice: Undefined index: f_name in C:\wamp\www\music website\register.php on line 105

 

Notice: Undefined index: l_name in C:\wamp\www\music website\register.php on line 106

 

Notice: Undefined index: DOB in C:\wamp\www\music website\register.php on line 107

 

Notice: Undefined index: gender in C:\wamp\www\music website\register.php on line 108

 

Notice: Undefined index: address in C:\wamp\www\music website\register.php on line 109

 

Notice: Undefined index: pwd in C:\wamp\www\music website\register.php on line 110

 

Notice: Undefined index: pwd1 in C:\wamp\www\music website\register.php on line 111

 

Notice: Undefined index: e_address in C:\wamp\www\music website\register.php on line 112

 

and when i refresh the page the database is updating with 1 record but nothing in the fields

<?php

include ('connect.php');

?>

 

 

 

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Street Vybz Muzik | Register</title>

<link href="registerstyle.css" rel="stylesheet" type="text/css" />

 

<script src="register.js">

</script>

 

 

 

 

 

</head>

 

<body>

<div id="whole_page_content">

<div id="logo_image"> </div>

 

<div id="link_bg">

<div id="menu">

<ul>

<li><a href="index.html">Home</a></li>

<li><a href="news.html">News</a></li>

<li><a href="music.html">Music</a></li>

<li><a href="register.html">Register</a></li>

</ul>

</div>

 

 

</div>

<div id="other_link_background"></div>

 

<div id="member_registration">MEMBER REGISTRATION---PLEASE FILL OUT THE FOLLOWING FIELDS</div>

 

<div id="login_content">

 

 

 

<form name="registration"  action="register.php" method="POST" onSubmit="return validation(this);">

USERNAME:<br>

  Between 5-15 characters.             

  <input name="u_name" type="text"  size="35" maxlength="50">

  <br><br>

  FIRSTNAME:

  <br>

  Enter your first name.                    

  <input name="f_name" type="text" size="35" maxlength="50">

  <br><br>

  LASTNAME:

  <br>

  Enter your last name.

                      

  <input name="l_name" type="text" size="35" maxlength="50">

  <br><br>

DATE OF BIRTH:

  <br>

  Enter your Date of Birth.

                 

  <input name="DOB" type="text" size="35" maxlength="50"> (in MM/DD/YYYY format)

  <br><br>

  Gender

  <br>

  Select your gender.

                       

  <input name="gender" type="radio" value="male">MALE

  <input name="gender" type="radio" value="female">FEMALE

  <br><br>

ADDRESS:

  <br>

  Enter your ADDRESS

                    

  <input name="address" type="text" size="50" maxlength="50">

  <br><br>

  PASSWORD:

  <br>

  More than 5 characters.         

                

<input name="pwd" type="password" size="35" maxlength="50">

  <br><br>

  VERIFY PASSWORD:

  <br>

  Verify your password.

                   

<input name="pwd1" type="password" size="35" maxlength="50">

  <br><br>

  EMAIL:

  <br>

  Enter your email address.                

  <input name="e_address" type="text" size="35" maxlength="50">

  <br><br>

                  <input type="submit" value="Register" name="submit">

  <input name="reset" type="reset" value="Reset Information">

</form>

 

<?php

      $user  = $_POST['u_name'];

      $first  = $_POST['f_name'];

      $last  = $_POST['l_name'];

      $birth  = $_POST['DOB'];

      $sex        = $_POST['gender'];

      $addres    = $_POST['address'];

      $pass  = $_POST['pwd'];

      $conpass    = $_POST['pwd1'];

      $eaddress  = $_POST['e_address'];

     

 

 

 

 

 

$result= mysql_query("INSERT INTO user_accounts (username, firstname, lastname, birthday, gender, address, password, confirm_password, email_address)

VALUES ('$user', '$first', '$last', '$birth', '$sex', '$addres', '$pass', '$conpass', '$eaddress')");

 

 

 

 

 

 

 

 

 

 

 

?>

                                                                                                                                                                                                                               

                                                                                                                                                                                                                               

                                                                                                                                                                                                                               

                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

 

</div>

 

 

 

 

 

 

 

 

 

 

 

 

 

</div>

</body>

</html>[code=php:0]

Link to comment
https://forums.phpfreaks.com/topic/200699-undifined-index/
Share on other sites

if(isset($_POST['submit']))
{

    $user  = $_POST['u_name'];
      $first  = $_POST['f_name'];
      $last  = $_POST['l_name'];
      $birth   = $_POST['DOB'];
      $sex        = $_POST['gender'];
      $addres    = $_POST['address'];
      $pass   = $_POST['pwd'];
      $conpass    = $_POST['pwd1'];
      $eaddress  = $_POST['e_address'];
      





$result= mysql_query("INSERT INTO user_accounts (username, firstname, lastname, birthday, gender, address, password, confirm_password, email_address)
VALUES ('$user', '$first', '$last', '$birth', '$sex', '$addres', '$pass', '$conpass', '$eaddress')");

}

 

Have to wrap your code that handles submission into this conditional

Link to comment
https://forums.phpfreaks.com/topic/200699-undifined-index/#findComment-1053185
Share on other sites

You have no conditional statement to check whether or not the form has been submitted. Also, you should never, ever place user supplied data in a DB query without first sanitizing it with mysql_real_escape_string(), by typecasting variables, etc.

Link to comment
https://forums.phpfreaks.com/topic/200699-undifined-index/#findComment-1053186
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.