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
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
}

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

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;

Link to comment
Share on other sites

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.

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.