0

how do i create php page with the following attributes(emp_id,emp_password,emp_address,emp_fname and emp_lname)tha will be posted to the data base?

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by lyrico
0

To do this, you need to create two pages (you can also use one page) one with a form to collect input from the user and other is where you will do your processing. For the first page you can create a form like this:

<form method = "post" action = "processing_page.php">
<input type = "text" name = "user_id">
<input type = "text" name = "first_name">
<input type = "text" name = "last_name">
<input type = "password" name = "user_pass">
<input type = "submit" name = "send" value = "SEND">
</form>

The value of action in the first line of the code above is the page where you will process the user's input.
On the processing_page.php you will access the values that the user entered in the form as follows:

$_POST['user_id']; //Value that the user enter in the user_id field
$_POST['first_name']; //Value that the user enter in the first_name field
$_POST['last_name']; //Value that the user enter in the last_name field
$_POST['user_pass']; //Value that the user enter in the user_pass field

You can now insert these values into you database

0

Try this. Lets say we save this php as savedb.php

<?php

//database connection here

echo "<form action='savedb.php' method='post'>";
echo "<input type='text' name='empid'>"."<br/>";
echo "<input type='text' name='password'>"."<br/>"; //or use <input type='password'>
echo "<input type='text' name='address'>"."<br/>";
echo "<input type='text' name='first_name'>"."<br/>";
echo "<input type='text' name='last_name'>"."<br/>";
echo "<input type='submit' name='submit' value='Save'>";
echo "</form>";

if($_POST['submit']=="Save")
{
  $empid = $_POST['empid'];
  $pass = $_POST['password'];
  $addr = $_POST['address'];
  $fname = $_POST['first_name'];
  $lname = $_POST['last_name'];

  mysql_query("INSERT INTO table_name (emp_id,emp_password,emp_address,emp_fname,emp_lname) values ('$empid','$pass','$addr','$fname','$lname')");
}

?>

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.