Forums Gallery Movies File Hosting Classifieds Jokes Free Hosting Free Blogs

Go Back   BizHat Forums > Computer Forum > PHP Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-05-2009, 05:27 PM
Junior Member
BizHat Newbie
 
Join Date: May 2009
Posts: 5
Default The $_GET variable

I am trying to get values from firstpage.php and send them to secondpage.php this is what i have figured out and i am wondering if it is the correct way to do it thanks.

Firstpage.php

PHP Code:
 <?php
//Connects to the database.
$con mysql_connect("localhost","blank","blank") or die (mysql_error());
$db mysql_select_db("wsdatabase") or die (mysql_error());
// Selects username's from the user table.
$sql "select username from users";
$query mysql_query($sql);
// List's every name in the table with a link going to the secondpage.php.
while($row mysql_fetch_array($query)) {
    
printf("<a href='secondpage.php?username=%s'>%s</a>"."<br/>",$row['username'],$row['username']);
}
?>
secondpage.php

PHP Code:
 <?php
// Grabs the username with the get method.
if(isset($_GET['username'])) {
    
$username $_GET['username'];
}
// Connects to the database.
$con mysql_connect("localhost","blank","blank") or die (mysql_error());
$db mysql_select_db("wsdatabase") or die (mysql_error());
// Selects everything from the database.
$sql "select * from users where username = '$username' ";
$query mysql_query($sql);
// Prints everything out from the database.
while($row mysql_fetch_array($query)) {
    echo 
"<b>".$row['title']."</b>";
    echo 
"<br/>";
    echo 
"<b>".$row['username']."</b>";
    echo 
"<br/>";
    echo 
"<b>".$row['email']."</b>";
}
?>
Reply With Quote
  #2 (permalink)  
Old 06-25-2009, 04:07 PM
Junior Member
BizHat Newbie
 
Join Date: Jun 2009
Posts: 7
Default

I think it work ok, but in my opinion this is not really a good way.
If i were you, I will use POST method to avoid posting variable to address
Btw, you should print some thing when there is no username match $_GET['username'], kind da like: User name ABC not found or st
Reply With Quote
  #3 (permalink)  
Old 09-12-2009, 07:03 PM
Junior Member
BizHat Newbie
 
Join Date: Sep 2009
Posts: 4
Default

what is '%s' ?
Reply With Quote
  #4 (permalink)  
Old 11-16-2009, 03:01 PM
Junior Member
BizHat Newbie
 
Join Date: Nov 2009
Posts: 9
Default

Quote:
Originally Posted by topsitex View Post
what is '%s' ?
joining the question .
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:26 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0