Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to insert record using PHP MySQL?
    primarykey
    data
    text
    <p>I created database(my_db) and table(persons) in which i used three fields FirstName,LastName and Age. I run below php script it shows error like:</p> <p>( ! ) Notice: Undefined index: FirstName in C:\wamp\www\insert.php on line 5 Call Stack </p> <h1>Time Memory Function Location</h1> <p>1 0.0007 369800 {main}( ) ..\insert.php:0 </p> <p>( ! ) Notice: Undefined index: LastName in C:\wamp\www\insert.php on line 6 Call Stack </p> <h1>Time Memory Function Location</h1> <p>1 0.0007 369800 {main}( ) ..\insert.php:0 </p> <p>( ! ) Notice: Undefined index: Age in C:\wamp\www\insert.php on line 7 Call Stack </p> <h1>Time Memory Function Location</h1> <p>1 0.0007 369800 {main}( ) ..\insert.php:0 Records added to the database </p> <p>BELOW IS THE PHP CODE: PLS HELP ME AND THANKS IN ADVANCE</p> <pre><code> &lt;html&gt; &lt;body&gt; &lt;?php $first=$_POST ['FirstName']; $last=$_POST ['LastName']; $a=$_POST ['Age']; $user_name = "root"; $password = ""; $database = "my_db"; $server = "127.0.0.1"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "INSERT INTO persons(FirstName, LastName, Age) VALUES ('$first', '$last', '$a')"; $result = mysql_query($SQL); mysql_close($db_handle); print "Records added to the database"; } else { print "Database NOT Found "; mysql_close($db_handle); } ?&gt; </code></pre> <p> </p> <pre><code> AND HTML FORM IS BELOW: &lt;html&gt; &lt;body&gt; &lt;form action="insert.php" mehtod="POST"&gt; First Name: &lt;input type="text" name="FirstName"&gt; &lt;br /&gt; Last Name:&lt;input type="text" name="LastName"&gt; &lt;br /&gt; Age:&lt;input type="text" name="Age"&gt; &lt;br /&gt; &lt;input type="submit" value="ADD" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload