Jump to content

[SOLVED] compare 2 text boxes


jeff5656

Recommended Posts

Can someone tell me how to compare content from a text box submitted from a form with the content from the database?

 

the form will have $_POST['problist'] and the the database variable is problist.

 

I want to query the databse and get "problist" and then compare it to $_POST['problist'].

If they are different I want to update another field ("problist_date") with with today's date (to show the date of when that textbox was altered).

Thank you!

Link to comment
https://forums.phpfreaks.com/topic/131957-solved-compare-2-text-boxes/
Share on other sites

I have this.  is this correct?  I can't test it yet but I thinbk the query line is slightly wrong...

$current_date = date ("m/d/y"); 
$query = "SELECT * FROM `icu` WHERE `patient` = '$_POST['patient']' ";
$results = mysql_query ($query) or die (mysql_error());

if($problist != $_POST[problist]) {
$problist_date = $current_date
}

here you go

 

<?php $current_date = date ("m/d/y");
$query = "SELECT * FROM `icu` WHERE `patient` = '".$_POST['patient']."' ";
$results = mysql_query ($query) or die (mysql_error());

if($problist != $_POST[problist]) {
$problist_date = $current_date;
}?>

 

from '$_POST['patient']' to '".$_POST['patient']."'

 

and

 

$current_date  to

$current_date;

Thanks.  Now the problem is when I echo problist it is null, even though I know it contains text.

Since I used * to select all the fields, why is it not returning the content?

 

$current_date = date ("m/d/y");
$query = "SELECT * FROM `icu` WHERE `patient` = '".$_POST['patient']."' ";
$results = mysql_query ($query) or die (mysql_error());

if($problist != $_POST[problist]) {
$problist_date = $current_date;
}

echo $_POST['patient'];
echo $_POST['problist'];
echo "<p>";
echo "problist:";
echo $problist;
echo "<br/>";
echo $problist_date;
echo $current_date;

and where you getting $_post from

 

from a form where the user can edit the fields from that record. If they edit a field, I want to put in tpday's date to show that the field was updated.

 

also,

echo $_POST['problist']; 

gives me the correct contents from that submitted form.

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.