Jump to content

[SOLVED] MySQL, HTML Form, PHP


sanchez77

Recommended Posts

Ok, So I have an HTML form that submits data to a table.

 

Here is the form:

<form method=post action="submit.php">
  <div align="center">
Your Name:  
  <input name="name" type="text" size="45" />
    <br />
  <input type="submit" value="Post Info" />
</div>
</form>

 

It uses this PHP script to post the field to the table:

    <?php

mysql_select_db("my_db", $con);$sql="INSERT INTO people name)
VALUES
('$_POST[name]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
echo "<center>Thanks</center>";mysql_close($con)

?>

 

I have another table called phone and I want to query that table phone when I submit the form and take the last row field value and insert it into the people table. How do you do that?

 

Link to comment
https://forums.phpfreaks.com/topic/158490-solved-mysql-html-form-php/
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.