Jump to content

Multipage Form using Mysql's AI


Colton.Wagner

Recommended Posts

I have tried this for about 2 solid hours and I cannot figure out how to make multiple forms that have the same ID.

 

Definition: I have 3 pages and they all have different information that needs to be placed into the database. I have no problem doing that the trouble comes when I try to make the 3 different database entry's have the same ID as the first form. My thought was to have the first form be completed then after the data was placed it would use mysql to pull the ID back out by using the WHERE clause to match the persons last name.

 

//Connection to the Mysql_Database
$con = mysql_connect("####", "####", "####");
if(!$con){
	die("There was an error connecting to your mysql_database" . mysql_error());
}
//Variables to be entered into Patient_Data
$last_name = $_POST['last_name'];

//Intialize and Select the correct database.
mysql_select_db("####");

//Format the data for entry into the mysql Database.
$query = mysql_query("INSERT INTO Patient_Data VALUES ('', '$last_name)");

//Verify that the operation has worked
if(!$query){
	die("Lost in Transmission!" . mysql_error());
}

$id_find = mysql_query("SELECT * FROM #### WHERE last_name='$last_name'");

while($id =  mysql_fetch_row($id_find)){?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form name="MedicalHistory" action="https://evansvillesurgical.com/med-record.php?id=<?php echo $id['id'];}?>" enctype="application/x-www-form-urlencoded" method="post">

 

Any help would be greatly appreciated. Even if it's just describing in Pseduo code a better way to go about this.

Thanks,

Colton Wagner

Link to comment
Share on other sites

You can use mysql_insert_id() to get the PK ID number of the record, then use it to UPDATE the record with subsequent forms. Another way would be to store the form data in a $_SESSION variable for each form, then INSERT it all at once, after the last form has been submitted.

Link to comment
Share on other sites

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.