hai everyone..i have run this file in my server.the following error is display

Notice: Undefined index: name in F:\wamp\www\examples1\register.php on line 8

Notice: Undefined index: username in F:\wamp\www\examples1\register.php on line 9

Notice: Undefined index: emailid in F:\wamp\www\examples1\register.php on line 10

Notice: Undefined index: password in F:\wamp\www\examples1\register.php on line 11

Notice: Undefined index: cpassword in F:\wamp\www\examples1\register.php on line 12
Anyone help me..

<?php
$host ='localhost';
$user ='root';
$password ='';
$database ='dta';
$conn = mysql_connect($host,$user,$password)or die ('server is not connect');
mysql_select_db($database,$conn);
$name = mysql_real_escape_string($_POST['name']);
$username = mysql_real_escape_string($_POST['username']);
$emailid = mysql_real_escape_string($_POST['emailid']);
$password = mysql_real_escape_string($_POST['password']);
$cpassword = mysql_real_escape_string($_POST['cpassword']);
if(isset($_POST['submit']))
{
$query = " insert into users(name,username,emaiid,password,)values ('$name','$username','$emailid','$password')";
$res = mysql_query($query);
header('location:register_success.php');
exit();
}
?>
<html>
<head>
<title> registeration form</title>
</head>
<body>
<form>
<form id= "register form" name="register form" method="post" action="">
  <table width="300" border="0" align="center" cellpadding="2" cellspacing="0">
  <tr>
      <th> name </th>
      <td><input name="name" type="text" class="textfield" id="name" /></td>
    </tr>
    <tr>
      <th>user name </th>
      <td><input name="username" type="text" class="textfield" id="user name" /></td>
    </tr>
    <tr>
      <th width="124">email id</th>
      <td width="168"><input name="emailid" type="text" class="textfield" id="email id" /></td>
    </tr>
    <tr>
      <th>Password</th>
      <td><input name="password" type="password" class="textfield" id="password" /></td>
    </tr>
    <tr>
      <th>Confirm Password </th>
      <td><input name="cpassword" type="password" class="textfield" id="cpassword" /></td>
    </tr>
    <tr>
      <td> </td>
      <td><input type="submit" name="submit" value="Create account" /></td>
    </tr>
  </table>
</form>
</body>
</html>

A $_POST variable may not have a value, so you should do the following:

$name = isset($_POST['name']) ? mysql_real_escape_string($_POST['name']) : '';

or move the assignments within the if.

Add on: Your query is incorrect, check that you have the syntax right.

hai.thanks.nw script is working.but i am new beginner for php developer.y used for this ?something :'';
pls tell me

hai.thanks.nw script is working.but i am new beginner for php developer.y used for this ?something :' ';
pls tell me

It's called the ternary operator, a shorthand if/else construct. See the manual, example #2.

suppose i fill the form and click the submit button.the pages not go to next page.but i includer the header funtion.header('location:register_success.php');

Did you fix your query, as I mentioned earlier ?

$query = " insert into users(name,username,emailid,password,)values ('$name','$username','$emailid','$password')";
i think query is correct

my table name is users. my table is create table users(id int(11) auto increment,name varchar(100),username varchar(100),email id varchar (100), password varchar(100), primary key(id));

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.