-
Posts
110 -
Joined
-
Last visited
Everything posted by bullbreed
-
wow. how good are you. how do I get that information in a table Heres my code; <table> <tr> <th>Name</th> <th>Username</th> <th>Email</th> <th>Training Required</th> <th>Date Submitted</th> </tr> <?php $sql = "SELECT `users`.`name`,`users`.`username`,`users`.`email`,`trainingdata`.`description`,`trainingdata`.`date` FROM `users` INNER JOIN `trainingdata` USING (`username`) WHERE `users`.`username`='".$_GET['username']."' LIMIT 1"; $sql_query = mysql_query($sql) or trigger_error(mysql_error()); if (mysql_num_rows($sql_query) > 0) { $data = mysql_fetch_assoc($sql_query); } ?> <tr> <td><?php echo $row['name']; ?></td> <td><?php echo $row['username']; ?></td> <td><?php echo $row['email']; ?></td> <td><?php echo $row['description']; ?></td> <td><?php echo $row['email']; ?></td> </tr> </table>
-
I kind of know what you mean. I have a row of information in a page called clients.php. This row shows some of the data held in the 'users' table in the db. At the end of this row is a 'more' link like this Name-----------------Username-------------Email-----------------More Info Bob--------------------Bobby01--------------bob@bob.com------More When the 'More' link is clicked it will go to the clientinfo.php page like this <?php echo '<a href="clientinfo.php?username='.$row['username'].'">More</a>' ?> I want this new page to get name----username----email from the users table and description----date from the trainingdata table Relative to the user in the link. Baffled? I know I am. lol
-
I have 2 tables in my database that I want to pull the information out and show it on a page relative to s username. What would be the code I need to insert in to the SELECT FROM section of the following code to join a table called 'users' with a table called ''trainingdata' associated by the 'username' <table> <tr> <th>Name</th> <th>Username</th> <th>Email</th> <th>Training Required</th> <th>Date Submitted</th> </tr> <?php $sql = "SELECT `name`, `username`, `email` FROM users WHERE `userlevel`=1"; $query = mysql_query($sql) or die(myslq_error()); while($row = mysql_fetch_assoc($query)){ ?> <tr> <td><?php echo $row['name']; ?></td> <td><?php echo $row['username']; ?></td> <td><?php echo $row['email']; ?></td> <td><?php echo $row['description']; ?></td> <td><?php echo $row['date']; ?></td> </tr> <?php } ?> </table>
-
Ah I see. In my case the unique column in the table is the username. The reason being is that I have 2 tables and I needed a column in each so I can call the info from 2 tables (join). My register script wont let you register with a username that has already been taken. So when he user clicks on the link it will go to a new page clientinfo.php and show the data from both tables. Well, thats what I'm attempting anyway. lol
-
Hello. This may be a simple one but I have used a php script that calls some information out of the database and shows it in a row below the headers like this; Name--------------Username-----------Email-----------------More Info Bob [email protected] Mary [email protected] Bill [email protected] Dan [email protected] What I want to know is the code I would put in the More link at the end that would open a new page and show information from the database that is relevant to the username of the person. Heres what I have so far <table> <tr> <th>Name</th> <th>Username</th> <th>Email</th> <th>More Info</th> </tr> <?php $sql = "SELECT `name`, `username`, `email` FROM users WHERE `userlevel`=1"; $query = mysql_query($sql) or die(myslq_error()); while($row = mysql_fetch_assoc($query)){ ?> <tr> <td><?php echo $row['name']; ?></td> <td><?php echo $row['username']; ?></td> <td><?php echo $row['email']; ?></td> [color=red]<td><a href="WHAT GOES HERE">More</a></td>[/color] </tr> <?php } ?> </table>
-
No sorry, doesnt work Also I dont want the user to click on a refresh link, thats too confusing for them
-
Any other takers please?
-
If I can get it working i'll post the code. Problem is i'm brand new at php and still dont understand most of it. Troubleshooting is difficult when you know what your doing, never mind when you dont.
-
I am new to php so please bear with me. I added if (isset($_SESSION['username'])) { echo "Your In! "; $_SESSION['username'] = $username; echo "Welcome, ".$_SESSION['username']."! <br /><a href='includes/logout.php'>Log out</a>"; } else { (Then closed this at the bottom of the page as per the code below.) to the code and I know it isn't pretty but it almost works. Now when I log and i go to a new page the message says; Your in! ******** Welcome ! Log out The isue with this is that it isnt showing the usrname in the session Additions are marked in red. If this is completely wrong, what have I done. could someone do a sample code that it should be so I can compare. Easier to learn that way? <?php session_start(); ?> <div id="header"> <div class="login"> <?php [color=red] if (isset($_SESSION['username'])) { echo "Your In! "; $_SESSION['username'] = $username; echo "Welcome, ".$_SESSION['username']."! <br /><a href='includes/logout.php'>Log out</a>"; } else { [/color] //Get the Username and Password $username = $_POST['username']; $password = $_POST['password']; if ($username && $password){ $connect = mysql_connect("localhost", "root", "") or die("Couldn't connect!"); mysql_select_db("*****") or die("Couldn't find Database!"); $query = mysql_query("SELECT * FROM users WHERE username = '$username'"); $numrows = mysql_num_rows($query); if ($numrows != 0){ // code to login $row = mysql_fetch_assoc($query); $dbusername = $row['username']; $dbpassword = $row['password']; // Check to see if they match! if ($username == $dbusername && md5($password) == $dbpassword){ echo "Your In! "; $_SESSION['username'] = $username; echo "Welcome, ".$_SESSION['username']."! <br /><a href='includes/logout.php'>Log out</a>"; }else{ echo "Incorrect username or password!"; } }else{ echo "That user doesn't exist!"; } }else{ echo "Please enter a username and a password!"; } if (!isset($_SESSION['username'])){ ?> <form action='index.php' method='POST'> Username: <input name='username' type='text' size="20" maxlength="25" /><br /> Password: <input name='password' type='password' size="20" maxlength="25" /><br /> <input type='submit' name'login' value='Login' " /> or <a href='member-register.php'>Register!</a> </form> <?php } [color] } [/color] ?> </div> </div>
-
Hello. I am trying do develop a login system that all works on the same page (i.e clicking login doesnt go to another page to tell you that you are logged in or display any errors like missing fields etc.) I want it all to happen in a small div in the header section of the website I have got this far (see code below) But what happens is, when i click on login it works fine but when i then click on another page the message changes to "Please enter a username and password. Your help is very much appreciated <?php session_start(); ?> <div id="header"> <div class="login"> <?php $username = $_POST['username']; $password = $_POST['password']; if ($username && $password){ $connect = mysql_connect("localhost", "root", "") or die("Couldn't connect!"); mysql_select_db("********") or die("Couldn't find Database!"); $query = mysql_query("SELECT * FROM users WHERE username = '$username'"); $numrows = mysql_num_rows($query); if ($numrows != 0){ // code to login $row = mysql_fetch_assoc($query); $dbusername = $row['username']; $dbpassword = $row['password']; // Check to see if they match! if ($username == $dbusername && md5($password) == $dbpassword){ echo "Your In! "; $_SESSION['username'] = $username; echo "Welcome, ".$_SESSION['username']."! <br /><a href='includes/logout.php'>Log out</a>"; }else{ echo "Incorrect username or password!"; } }else{ echo "That user doesn't exist!"; } }else{ echo "Please enter a username and a password!"; } if (!isset($_SESSION['username'])){ ?> <form action='login.php' method='POST'> Username: <input name='username' type='text' size="20" maxlength="25" /><br /> Password: <input name='password' type='password' size="20" maxlength="25" /><br /> <input type='submit' value='Login' " /> or <a href='member-register.php'>Register!</a> </form> <?php } ?> </div> </div> [code]
-
Hi everyone. Martin here. Just wanted to say hello. I'm new to PHP and trying my best to do it well. I've been doing it for only a few days so your help is much appreciated.