Jump to content

Recommended Posts

i m new in php i make two pages first was first.php

the second was insert.php the codes are below but it show  Notice: Undefined index:

how to remove this error 

thanks 

 

first page 

 

<!DOCTYPE html>

<html>
<body>
<form id="firstform" action="insert.php" method="post">
<center> My First Page in PHP  </center>
<center>Name:<input type="text" id="name" size=20>
FatherName: <input type="text" id="fname" size=20> 
Address:<input type="text" id="add" size=20> 
<input type="submit" name="sub">
</form>
</body>
</html>
 
insert page 
 
<html>
<body>
<?php
 
$con=mysqli_connect("localhost","root","khan","first");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
 $sql="INSERT INTO bio(name, fathername , address) 
VALUES
('$_POST[name]','$_POST[fname]','$_POST[add]')";
 
if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }
echo "1 record added";
 
mysqli_close($con);
?>
</body>
</html>

 

Link to comment
https://forums.phpfreaks.com/topic/279224-notice-undefined-index/
Share on other sites

For example Address:<input type="text" id="add" size=20> might look something like <input type="text" name="address" id="address-style" size="20">

 

and your php:

$address = $_POST['address'];
Edited by Strider64
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.