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.

PHP MySql Help Needed

Postby SilentDIGGER » Tue May 12, 2009 2:20 pm

Hi all,
Ok I have this following code in php/html
Code: Select all
<?php //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=""> <tr> <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> </tr> <tr> <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> </tr> <tr> <input type="button" onClick="self.location=''" value="CMB LookUp" class="button"> </form>
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
SilentDIGGER
Hacker in Training
 
Posts: 71
Joined: Sun Mar 27, 2005 12:26 pm

Re: PHP MySql Help Needed

Postby 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."
User avatar
Aiden
Administrator
 
Posts: 1080
Joined: Tue Oct 31, 2006 11:11 pm
Location: /usr/bin/perl

Re: PHP MySql Help Needed

Postby BreadHog » Tue Apr 17, 2012 1:22 pm

If you have to get anything help regarding php/mysql then php.net 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.
BreadHog
Strike 1
 
Posts: 5
Joined: Tue Apr 17, 2012 9:38 am
Website: http://livecasino.smartlivegaming.com/live-roulette.html
Location: USA

Very good idea

Postby 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?
thailand
n00b
 
Posts: 2
Joined: Tue Mar 13, 2012 10:11 am

Re: PHP MySql Help Needed

Postby 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.
User avatar
Cool_Fire
Not a sandwich
 
Posts: 1880
Joined: Fri May 09, 2003 1:20 pm
ICQ: 336613081
Website: https://www.insomnia247.nl/
Yahoo Messenger: cool_fire_666
AOL: EvilCoolFire
Location: 41 6d 73 74 65 72 64 61 6d


Return to ā€œ%sā€ Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron