Login session

Thread Solved

Join Date: Mar 2008
Posts: 63
Reputation: sukhy_1 is an unknown quantity at this point 
Solved Threads: 3
sukhy_1 sukhy_1 is offline Offline
Junior Poster in Training

Login session

 
0
  #1
Mar 29th, 2008
Hello does anyone know how to bring details from a database into a textbox? becuase ive got the login working and it displays whos logged in but i want the postcode to appear in a textbox, the postcode is kept in mysql table called address.

/after connecting to mysql
  1. $query = "SELECT * FROM StudentRecords WHERE Email= '".$myusername."'";
  2. $result = mysql_query($query);
  3.  
  4. <td><input type="text" name="PickupAddressPostCode"</td>
Last edited by peter_budo; Mar 30th, 2008 at 6:19 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 154
Reputation: Suomedia is an unknown quantity at this point 
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: Login session

 
0
  #2
Mar 29th, 2008
  1. $query = "SELECT address_code FROM address WHERE userID= '".$myuserID."'";
  2. $result = mysql_query($query);
  3.  
  4. <td><input type="text" name="PickupAddressPostCode" value="<?php echo $result['address_code']; ?>" /></td>


Matti Ressler
Suomedia
Last edited by Suomedia; Mar 29th, 2008 at 12:24 pm.
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 63
Reputation: sukhy_1 is an unknown quantity at this point 
Solved Threads: 3
sukhy_1 sukhy_1 is offline Offline
Junior Poster in Training

Re: Login session

 
0
  #3
Mar 29th, 2008
thank u
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 154
Reputation: Suomedia is an unknown quantity at this point 
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: Login session

 
0
  #4
Mar 29th, 2008
Mark as solved
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 63
Reputation: sukhy_1 is an unknown quantity at this point 
Solved Threads: 3
sukhy_1 sukhy_1 is offline Offline
Junior Poster in Training

Re: Login session

 
0
  #5
Mar 29th, 2008
Its meant to select the postcode from the address table where the email matchs the login name which is myusername. and then display postcode in the textbox. it connects to database but in the textbox what the postcode is meant to appear in it says...
<br /><b>Notice</b>: Undefined variable: result in <b>/home/public_html/book.php</b> on line <b>79</b><br />


  1. <?
  2. $query = "SELECT PostCode FROM address WHERE
  3. Email= '".$myusername."'";
  4. $result = mysql_query($query);
  5. ?>
  6.  
  7. line 79 is here
  8. <td><input type="text" name="PickPostCode" value="<?php echo
  9. $result['PostCode ']; ?>" /></td>
Last edited by peter_budo; Mar 30th, 2008 at 6:19 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 154
Reputation: Suomedia is an unknown quantity at this point 
Solved Threads: 19
Suomedia Suomedia is offline Offline
Junior Poster

Re: Login session

 
0
  #6
Mar 29th, 2008
You need to connect to mySQL, select the database, make the query, fetch the result with mysql_fetch_array() and close the connection.


Matti Ressler
Suomedia
If you want your dreams to come true, the first thing you must do is to wake up....
Suomedia - Dynamic Content Management
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 63
Reputation: sukhy_1 is an unknown quantity at this point 
Solved Threads: 3
sukhy_1 sukhy_1 is offline Offline
Junior Poster in Training

Re: Login session

 
0
  #7
Mar 29th, 2008
ive got the connection the database connection and everything working expect that 1 notice
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,833
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 344
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Login session

 
0
  #8
Mar 29th, 2008
Originally Posted by Suomedia View Post
  1. $query = "SELECT address_code FROM address WHERE userID= '".$myuserID."'";
  2. $result = mysql_query($query);
  3.  
  4. <td><input type="text" name="PickupAddressPostCode" value="<?php echo $result['address_code']; ?>" /></td>


Matti Ressler
Suomedia

That should actually be
  1. $query = "SELECT address_code FROM address WHERE userID= '".$myuserID."'";
  2. $result = mysql_query($query);
  3. $row = mysql_fech_array($result); //or while($row = mysql_fetch_array($result)) if your query returns more than 1 row
  4. <td><input type="text" name="PickupAddressPostCode" value="<?php echo $row['address_code']; ?>" /></td>

Cheers,
Naveen
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 63
Reputation: sukhy_1 is an unknown quantity at this point 
Solved Threads: 3
sukhy_1 sukhy_1 is offline Offline
Junior Poster in Training

Re: Login session

 
0
  #9
Mar 30th, 2008
Still not working
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,833
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 344
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Login session

 
0
  #10
Mar 30th, 2008
Same error ? Try mysql_error() with die statement. Also print out your query and tell us what it says !
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 3871 | Replies: 29
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC