Jump to content

rdkd1970

Members
  • Posts

    163
  • Joined

  • Last visited

Everything posted by rdkd1970

  1. that created an error message but i did get the welcome to everyone of my tested members. Could it be my while loop and the numrows something i did wrong.
  2. Can someone help me I have been working on this problem for some time. I have coded my page to welcome, firstname. At first in my insert I had used the id I have not switched it to the username as id was including everyone of my test names in the welcome. It looks like the sessions are continuing as I am able to go to the private section of the pages. However I am not sure what I have to do to produce the welcome, firstname to go to all the pages and let me know it is allowing the one member to access the private sessions. Also when I use the login form it does not recognize the users. It is like the connection to the database dies i guess. here is my codes. <?php session_start(); ini_set ("display_errors", "1"); error_reporting(E_ALL); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Welcome</title> <style type="text/css"> .background {color: #B56AFF; } </style> </head> <body> <p> <?php /* Program: login.php * Desc: Displays the new member welcome page. Greets * member by name and gives a choice to enter * restricted section or go back to main page. */ if (isset($_SESSION['username'])) { // Set the users session ID include("Connections/connect_to_mysql.php"); //Formulate Query //This is the best way to perform an SQL query $query = mysql_query ("SELECT * FROM `Members` WHERE username={$_SESSION['username']}"); $result = mysql_query($query); $numrows = mysql_num_rows($query); //Check result //This shows the actual query sent to MySQL and the error. Useful for debugging. if(!$result){ $message = 'Invalid query:' . mysql_error() . "\n"; $message .= 'Whole query:' . $query; die($message); } //Use result //Attempting to print $result won't allow access to information in the resource //One of the mysql result functions must be used //See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. if($numrows!=0){ while($row = mysql_fetch_assoc($query)); $dbusername = $row['username']; $dbpassword = $row['password']; //check to see if they match! if($username==$dbusername&&md5($password)==$dbpassword){ echo "Welcome, ".$_SESSION['firstname']. "!<br><a href='logout_test.php'>Logout</a>"; } } } ?> </p> <p> </p> <p>Your new Member accounts lets you enter the members only section of our web site. You'll find special discounts, a profile of matches, live advise from experts, and much more.</p> <p>Your new Member ID and password were emailed to you. Store them carefully for future use.</p> <div style="text-align: center"> <p style="margin-top: .5in; font-weight: bold"> Glad you could join us!</p> <form action="profile.php" method="post"> <input type="submit" value="Enter the Members Only Section"> </form> <form action="index.php" method="post"> <input type="submit" value="Go to Main Page"> </form> </div> </body> </html> <?php session_start(); ini_set ("display_errors", "1"); error_reporting(E_ALL); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Welcome</title> <style type="text/css"> .background {color: #B56AFF; } </style> </head> <body> <p> <?php /* Program: login.php * Desc: Displays the new member welcome page. Greets * member by name and gives a choice to enter * restricted section or go back to main page. */ if (isset($_SESSION['username'])) { // Set the users session ID include("Connections/connect_to_mysql.php"); //Formulate Query //This is the best way to perform an SQL query $query = mysql_query ("SELECT * FROM `Members` WHERE username={$_SESSION['username']}"); $result = mysql_query($query); $numrows = mysql_num_rows($query); //Check result //This shows the actual query sent to MySQL and the error. Useful for debugging. if(!$result){ $message = 'Invalid query:' . mysql_error() . "\n"; $message .= 'Whole query:' . $query; die($message); } //Use result //Attempting to print $result won't allow access to information in the resource //One of the mysql result functions must be used //See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. if($numrows!=0){ while($row = mysql_fetch_assoc($query)); $dbusername = $row['username']; $dbpassword = $row['password']; //check to see if they match! if($username==$dbusername&&md5($password)==$dbpassword){ echo "Welcome, ".$_SESSION['firstname']. "!<br><a href='logout_test.php'>Logout</a>"; } } } ?> :'(
  3. Here is another way I tried it will display the Welcome not the name $row = mysql_fetch_assoc($result); if ($id == $row['firstname']){ echo "Welcome, $row['firstname']"; }
  4. When I was using the while statement it was welcoming everyone in the db. I changed the while for an if statement it is not producing anything could be how I have it laid out I tried different ways to code it. Here is my latest. $row=mysql_fetch_assoc($result); extract ($row); if ($id == $firstname){ echo "Welcome, $firstname";
  5. I am not using anyones codes on the welcome page I just adjusted what others thought would work for me. I am trying to learn as much as you know but this is my first time trying to go live with coding. I try all suggestions giving to me as I know you guys know more than I know. I am just a newbie that thought it was going to work right away but found out that sometimes I come across a puzzle to fix. If I offended anyone I am sorry.
  6. I get this message when adding the LIMIT code and to change the bottom code just states a syntax error on Welcome, $firstname. Warning: mysql_query() [function.mysql-query]: Access denied for user 'ebermy5'@'localhost' (using password: NO) in /home/ebermy5/public_html/login.php on line 41 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/ebermy5/public_html/login.php on line 41 Invalid query:Access denied for user 'ebermy5'@'localhost' (using password: NO) Whole query:SELECT id, firstname FROM `Members` WHERE id=id LIMIT 1
  7. Can someone tell me how to get my $row to just have the person logging in to be welcomed presently when I test the page it is welcoming everyone of the test names???? this is the welcome page after the form. But it is picking up all tested members??? <?php session_start(); ini_set ("display_errors", "1"); error_reporting(E_ALL); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Welcome</title> </head> <body> <?php /* Program: login.php * Desc: Displays the new member welcome page. Greets * member by name and gives a choice to enter * restricted section or go back to main page. */ if (isset($_SESSION['id'])) { include('Connections/connect_to_mysql.php'); // Set the users session ID $id=$_SESSION['id']; // Now let's initialize vars to be printed to page in the HTML section so our script does not return errors // they must be initialized in some server environments $firstname = ''; $lastname = ''; $country = ''; $email = ''; //Formulate Query //This is the best way to perform an SQL query $query = "SELECT id, firstname FROM `Members` WHERE id={$_SESSION['id']}"; $result = mysql_query($query); //Check result //This shows the actual query sent to MySQL and the error. Useful for debugging. if(!$result){ $message = 'Invalid query:' . mysql_error() . "\n"; $message .= 'Whole query:' . $query; die($message); } //Use result //Attempting to print $result won't allow access to information in the resource //One of the mysql result functions must be used //See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. while($row=mysql_fetch_assoc($result)){ echo "Welcome, {$row['firstname']}"; } } mysql_free_result($result); ?> <p>Your new Member accounts lets you enter the members only section of our web site. You'll find special discounts, a profile of matches, live advise from experts, and much more.</p> <p>Your new Member ID and password were emailed to you. Store them carefully for future use.</p> <div style="text-align: center"> <p style="margin-top: .5in; font-weight: bold"> Glad you could join us!</p> <form action="profile.php" method="post"> <input type="submit" value="Enter the Members Only Section"> </form> <form action="index.php" method="post"> <input type="submit" value="Go to Main Page"> </form> </div> </body> </html>
  8. Can anyone help me with my codes thanks.
  9. Here is my codes I was working on this earlier and sort of got side tracked thought I was continuing my questions. <?php session_start(); ?> <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Welcome</title> </head> <body> <?php /* Program: login.php * Desc: Displays the new member welcome page. Greets * member by name and gives a choice to enter * restricted section or go back to main page. */ include('Connections/connect_to_mysql.php'); // Get the user session id variable into a local php variable for easier use in scripting $id = $_SESSION['id']; // Now let's initialize vars to be printed to page in the HTML section so our script does not return errors // they must be initialized in some server environments $firstname = ''; $lastname = ''; $country = ''; $email = ''; //Formulate Query //This is the best way to perform an SQL query $query = "SELECT id, firstname FROM `Members` WHERE id='$id'"; $result = mysql_query($query); //Check result //This shows the actual query sent to MySQL and the error. Useful for debugging. if(!$result){ $message = 'Invalid query:' . mysql_error() . "\n"; $message .= 'Whole query:' . $query; die($message); } //Use result //Attempting to print $result won't allow access to information in the resource //One of the mysql result functions must be used //See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. while($row=mysql_fetch_assoc($result)){ echo "Welcome, {$row[firstname]}"; } //Free the resources associated with the result set mysql_free_result($result); ?> <p>Your new Member accounts lets you enter the members only section of our web site. You'll find special discounts, a profile of matches, live advise from experts, and much more.</p> <p>Your new Member ID and password were emailed to you. Store them carefully for future use.</p> <div style="text-align: center"> <p style="margin-top: .5in; font-weight: bold"> Glad you could join us!</p> <form action="profile.php" method="post"> <input type="submit" value="Enter the Members Only Section"> </form> <form action="index.php" method="post"> <input type="submit" value="Go to Main Page"> </form> </div> </body> </html>
  10. Yes I just did not have it in this sorry.
  11. Help...I almost had this but I included the password field in my form now it is not working. What was happening before I had all the tested members added to the Welcome page at once. When I put in the password field it is not welcoming anyone so sessions is not operating. // Get the user session id variable into a local php variable for easier use in scripting $id = $_SESSION['id']; // Now let's initialize vars to be printed to page in the HTML section so our script does not return errors // they must be initialized in some server environments $firstname = ''; $lastname = ''; $country = ''; $email = ''; //Formulate Query //This is the best way to perform an SQL query $query = "SELECT id, firstname FROM `Members` WHERE id='$id'"; $result = mysql_query($query); //Check result //This shows the actual query sent to MySQL and the error. Useful for debugging. if(!$result){ $message = 'Invalid query:' . mysql_error() . "\n"; $message .= 'Whole query:' . $query; die($message); } //Use result //Attempting to print $result won't allow access to information in the resource //One of the mysql result functions must be used //See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. while($row=mysql_fetch_assoc($result)){ echo "Welcome, {$row[firstname]}"; } //Free the resources associated with the result set mysql_free_result($result); At one point it when it was including everyone all at once it was able to view the private pages but the new update password takes me back to square one. It was showing a error message with SQL " after the WHERE clause where I had the id={$_SESSION['id']} so I just tested to see how the codes id='$id' would work and it does not have the echo Welcome, firstname. these codes are very tricky.
  12. Here is my form <?php error_reporting(E_ALL); ini_set("display_errors", 1); include_once ("Connections/connect_to_mysql.php"); $err=''; $id=''; $firstname=''; $lastname=''; $password=''; $country=''; $email=''; $_SESSION['$id']='id'; if(isset($_POST["submit"])){ // Validate form data if($_POST["firstname"]=='') $err.='Please enter First Name<br>'; if($_POST["email"]=='') $err.='Please enter Email<br>'; if($err==''){ // Check if there are duplicate entries in the 'contacts' table $sql_check = mysql_query("SELECT id FROM `Members` WHERE firstname='".addslashes($_POST["firstname"])."' and Email='".addslashes($_POST["email"])."'"); if($row = mysql_fetch_array($sql_check)){ $err.='Can not add duplicate entry<br>'; } else{ // adding new record to 'contacts' table $results = mysql_query("INSERT INTO Members (firstname,lastname,password,country,Email) values ('".mysql_real_escape_string($_POST["firstname"])."','".mysql_real_escape_string($_POST["lastname"])."','".mysql_real_escape_string($_POST["password"])."','".mysql_real_escape_string($_POST["country"])."','".mysql_real_escape_string($_POST["email"])."')") or die (mysql_error()); $id = mysql_insert_id(); $userid = mysql_insert_id(); // redirecting to success screen if($results){ header("Location: login.php"); }else die(mysql_error()); } } } ?> <html> <head> <title>Add New Contact</title> </head> <body> <h2>Register with us</h2> <?php echo $err==''?'''<p style="color:red;">'.$err.'</p>') ?> <form method="post" action="form.php"> <table border="0"> <tr> <td valign="middle">First Name:</td> <td><input type="text" name="firstname" size="30" value="<?php echo htmlspecialchars($firstname) ?>"></td> </tr> <tr> <td valign="middle">Last Name:</td> <td><input type="text" name="lastname" size="30" value="<?php echo htmlspecialchars($lastname) ?>"></td> </tr> <tr> <td valign="middle">Password:</td> <td><input type="password" name="password" size="32" value="<?php echo htmlspecialchars($password) ?>"></td> </tr> <tr> <td valign="middle">Country:</td> <td><input type="text" name="country" size="30" value="<?php echo htmlspecialchars($country) ?>"></td> </tr> <tr> <td valign="middle">Email:</td> <td><input type="text" name="email" size="30" value="<?php echo htmlspecialchars($email) ?>"></td> </tr> </table><br> <input type="submit" name="submit" value=" Submit! "> </form> </body> </html> Here is my welcome page <?php session_start(); ?> <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Welcome</title> </head> <body> <?php /* Program: login.php * Desc: Displays the new member welcome page. Greets * member by name and gives a choice to enter * restricted section or go back to main page. */ include('Connections/connect_to_mysql.php'); $id = ''; $firstname = ''; $lastname = ''; $country = ''; $email = ''; //Formulate Query //This is the best way to perform an SQL query $query = "SELECT id, firstname FROM `Members` WHERE id={$_SESSION['id']}"; $result = mysql_query($query); //Check result //This shows the actual query sent to MySQL and the error. Useful for debugging. if(!$result){ $message = 'Invalid query:' . mysql_error() . "\n"; $message .= 'Whole query:' . $query; die($message); } //Use result //Attempting to print $result won't allow access to information in the resource //One of the mysql result functions must be used //See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. while($row=mysql_fetch_assoc($result)){ echo "Welcome, {$row[firstname]}"; } //Free the resources associated with the result set mysql_free_result($result); ?> <p>Your new Member accounts lets you enter the members only section of our web site. You'll find special discounts, a profile of matches, live advise from experts, and much more.</p> <p>Your new Member ID and password were emailed to you. Store them carefully for future use.</p> <div style="text-align: center"> <p style="margin-top: .5in; font-weight: bold"> Glad you could join us!</p> <form action="profile.php" method="post"> <input type="submit" value="Enter the Members Only Section"> </form> <form action="index.php" method="post"> <input type="submit" value="Go to Main Page"> </form> </div> </body> </html>
  13. Okay I added the password field in my form (not sure why I had it out in the first place) but I updated that to my form and did nothing to the Welcome page but now I get this message. Notice: Undefined index: id in /home/ebermy5/public_html/login.php on line 32 Invalid query:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Whole query:SELECT id, firstname FROM `Members` WHERE id= :-\
  14. I noticed that happened after i put in the var_dump so I removed it I am going to make changes to my form. Thanks for all your help. I will come back after I check a few things. Just glad to be getting as far as I got with your help.
  15. var_dump results in this error message Notice: Undefined index: id in /home/ebermy5/public_html/login.php on line 32 string(45) "SELECT id, firstname FROM `Members` WHERE id=" Invalid query:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Whole query:SELECT id, firstname FROM `Members` WHERE id=
  16. This is the SQL in my phpmyadmin SELECT * FROM `Members` WHERE 1 It is automatically there.
  17. the primary key in my tables is id only
  18. this is the new error message Notice: Use of undefined constant firstname - assumed 'firstname' in /home/ebermy5/public_html/login.php on line 48 Welcome, Steven It repeats all the names I put in the db as a test. so I am not sure if I have to use the email 1 as a confirmation that it is one member but then I have the problem of needing an email address to test lots of them.
  19. That still welcomes everyone by firstname and just gives them their own line. Should I put $col instead of $row.
  20. We are almost there I am jumping out of my skin.....
  21. We must be getting somewhere as I am not getting any messages but I think it has welcomed everyone at the same time. Here is what I get Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Welcome, Your new Member accounts lets you enter the members only section of our web site. .....
  22. Sorry I got lost for a moment but I did this to it and now I get this message. Notice: Undefined variable: query in /home/ebermy5/public_html/login.php on line 39 Invalid query:Unknown column '$id' in 'where clause' Whole query: $result = mysql_query("SELECT id, firstname FROM `Members` WHERE id={$_SESSION['id']}"); //Check result //This shows the actual query sent to MySQL and the error. Useful for debugging. if(!$result){ $message = 'Invalid query:' . mysql_error() . "\n"; $message .= 'Whole query:' . $query; die($message); } //Use result //Attempting to print $result won't allow access to information in the resource //One of the mysql result functions must be used //See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. while($row=mysql_fetch_assoc($result)){ echo "Welcome, $firstname"; } //Free the resources associated with the result set mysql_free_result($result);
  23. this is my update and error message is Invalid query:Query was empty Whole query: $query = mysql_query("SELECT id, firstname FROM `Members` WHERE $id={$_SESSION['id']}"); //Perform Query $result=mysql_query($query); //Check result //This shows the actual query sent to MySQL and the error. Useful for debugging. if(!$result){ $message = 'Invalid query:' . mysql_error() . "\n"; $message .= 'Whole query:' . $query; die($message); } //Use result //Attempting to print $result won't allow access to information in the resource //One of the mysql result functions must be used //See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. while($row=mysql_fetch_assoc($result)){ echo "Welcome, $firstname"; } //Free the resources associated with the result set mysql_free_result($result);
  24. I replaced it with echo "Welcome, $firstname"; still get no results. Could it be still not accepting the $result in this line.... while($row=mysql_fetch_assoc($result)){ echo "Welcome, $firstname";
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.