PHP MySql Help Needed

Talk about any languages right here. Share and discuss source, but don't expect your homework to be done for you.
Post Reply
User avatar
Hacker in Training
Posts: 71
Joined: Sun Mar 27, 2005 12:26 pm

PHP MySql Help Needed

Post by SilentDIGGER » Tue May 12, 2009 2:20 pm

Hi all,
Ok I have this following code in php/html

Code: Select all

//all the db, connect ,table is defined here

$memberLastName = $_POST['lastName'];
$memberFirstName  = $_POST['firstName'];

	//create and execute query
$query = "SELECT last_name,first_name FROM $usertable WHERE last_name = '$memberLastName' ";
	$result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error());
while($row = mysql_fetch_row($result))

echo $_POST['last_name'];   // its not showing
echo $_POST['first_name']; // its not showing
$memberLastName = $row['last_name']; // its not showing
$memberFirstName = $row['first_name']; // its not showing



//here goes the html code that has lastName and firstName
<FORM NAME="myform" method="POST" action="">
    <td nowrap="true" class="primary" valign="top">
      Last Name:    </td>
    <td valign="top" class="primary">
      <input type="text" name="lastName" <?php echo "value=\"$LastName\"" ?>   onChange="modified=true" />    </td>

    <td nowrap="true" class="primary" valign="top">
      First Name:    </td>
    <td valign="top" class="primary">
      <input type="text" name="firstName" <?php echo "value=\"$FirstName\"" ?> onChange="modified=true" />    </td>
<input type="button" onClick="self.location=''" value="CMB LookUp" class="button">
Now the thing that I'm trying to accomplish is when user enters their last name in the field "lastName" and presses "CMB LookUp" button, the $query gets executed and if there is lastName in $usertable fields lastName and firstName get filled accordingly, now everytime I do it I get no values, like I'm doing reset or something. So, I'm missing something, I googled it like crazy, and what I found didn't help, by the way this is part of openbiblio , if it matters.
Anyways I would appreciate any pointers, I need a fresh pair of eyes on this one.

Thanks in advance.

:) :)

User avatar
Posts: 1080
Joined: Tue Oct 31, 2006 11:11 pm
Location: /usr/bin/perl

Re: PHP MySql Help Needed

Post by Aiden » Wed May 13, 2009 3:16 pm

D'oh! I almost didn't catch it.
echo $_POST['last_name']; // its not showing
echo $_POST['first_name']; // its not showing
<input type="text" name="lastName" <?php echo "value=\"$LastName\"" ?> onChange="modified=true" />
<input type="text" name="firstName" <?php echo "value=\"$FirstName\"" ?> onChange="modified=true" />
Notice the discrepancies between the variable names. ;)
"When it takes forever to learn all the rules, no time is left for breaking them."

Strike 1
Posts: 5
Joined: Tue Apr 17, 2012 9:38 am
Location: USA

Re: PHP MySql Help Needed

Post by BreadHog » Tue Apr 17, 2012 1:22 pm

If you have to get anything help regarding php/mysql then is the great website for that. There is the complete information regarding the php and it's native function are located in it. Which is very useful for you.

Posts: 2
Joined: Tue Mar 13, 2012 10:11 am

Very good idea

Post by thailand » Sat Apr 28, 2012 2:30 pm

It was specially registered atr a forum to tell to you thanks for the information,can, I too can help you something?

User avatar
Not a sandwich
Posts: 1890
Joined: Fri May 09, 2003 1:20 pm
Location: 41 6d 73 74 65 72 64 61 6d

Re: PHP MySql Help Needed

Post by Cool_Fire » Fri Jun 15, 2012 6:32 am

You should probably keep in mind that this code is going to be susceptible to SQL injection.
And you should switch to the mysqli driver (rather than the obsoleted mysql driver).
Or better still, the PDO driver. And use prepared statements.
If we're breaking the rules, then how come you can't catch us? You can't find us? I know why. Cause, it's ... MAGIC!
Hackerthreads chat, where the party is going 24/7.

Post Reply