Jump to content

mikebyrne

Members
  • Posts

    780
  • Joined

  • Last visited

Everything posted by mikebyrne

  1. Getting the error Parse error: syntax error, unexpected ')' in C:\xampp\htdocs\MainPage\login.php on line 134 Line 134 is: if (mysql_num_rows($result) > 0)) {
  2. Im trying to code a searchfield in my site but im getting the error: Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\MainPage\login.php on line 138 line 138 is: } else { My code so far is: <table width="100%" cellpadding="0" cellspacing="0" border="0" class="b1sw2" style="background:url(Pictures/searchbox_bg.gif) no-repeat #003;"> <col width="1%"> <col width="99%"> <tr> <td> </td> <td> <label for="searchfield" class="t10nw"></label><br /><br /><br /><br /><br /><br /> <?PHP include("adminconnect.php"); $tbl_name = "product"; $cat = mysql_real_escape_string($_POST['cat']); $input = mysql_real_escape_string($_POST['searchfield']); $query = "SELECT * FROM $tbl_name WHERE $cat LIKE '%$input%'"; $result = mysql_query($result); while($row = mysql_fetch_array && mysql_num_rows($result) > 0) { $product = $row['product']; echo "".$product." was found. "; } else { echo "No search results found"; } ?> <select name="cat" onChange="setAction(this.options[this.selectedIndex].value);"> <option value="cd" selected="selected" >CDs</option> <option value="dvd" >DVDs</option> <option value="game" >Games</option> </select> <form name="ex2" method="get" action="/searchresults_cd.php"> <input type="text" name="searchfield" size="22" maxlength="40" id="srchdrop" /> <input type="submit" value="Search Now! »" id="gosrch" /> </td></tr> </form> </table>
  3. Im still not sure why its not going to password.php
  4. Im coding a password retrival box for my site but instead of running the php the page just loads member_login.php when I press the send password button. my code is: <form action="login.php" method="POST"> <div align="right">Pleas enter your Login Name</b> <BR>(This is the name you signed up with)</div> </td> <td width="50%"> <input type="text" name="uname" size="12" maxlength="50" class="field"> </td> </tr> <tr> <td class="bgrl"> <div align="right">Please enter your <b>password</b></div> </td> <td width="50%" class="bgrl"> <input type="password" name="pword" size="18" class="field"> </td> </tr> <tr><td> </td> <td> <input type="submit" value="Login »" name="login_form" class="submit"></form></td> </tr> <tr><td colspan="2" class="genericside"><span class="t11bw">Forgotten your password?</span></td> </tr> <tr valign="top"> <td class="alignright"> <form name="passwordreminder" action="password.php" method="post"> <input type="hidden" name="type" value="passwordreminder"> Please enter your email here:</td> <td><input type="text" name="reminderemail" class="field" maxlength="50"><br> <input type="submit" value="Send Password »" class="submit"> </form> Password.php looks like <? $host="localhost"; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name="admin"; // Database name //Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); // value sent from form $email_to=$_POST['passwordreminder']; // table name $tbl_name=adminusers; // retrieve password from table where e-mail = $email_to(mark@phpeasystep.com) $sql="SELECT password FROM $tbl_name WHERE email='$email_to'"; $result=mysql_query($sql); // if found this e-mail address, row must be 1 row // keep value in variable name "$count" $count=mysql_num_rows($result); // compare if $count =1 row if($count==1){ $rows=mysql_fetch_array($result); // keep password in $your_password $your_password=$rows['password']; // ---------------- SEND MAIL FORM ---------------- // send e-mail to ... $to=$email_to; // Your subject $subject="Your password here"; // From $header="from: your name <your email>"; // Your message $messages= "Your password for login to our website \r\n"; $messages.="Your password is $your_password \r\n"; $messages.="more message... \r\n"; // send email $sentmail = mail($to,$subject,$messages,$header); } // else if $count not equal 1 else { echo "Not found your email in our database"; } // if your email succesfully sent if($sentmail){ echo "Your Password Has Been Sent To Your Email Address."; } else { echo "Cannot send password to your e-mail address"; } ?>
  5. Im trying to code a searchfeld for my site but Im a little confused as to how I should go about it I think the php should be as below but im a little unsure about the sql <?php include("adminconnect.php"); $tbl_name = "products"; SELECT * FROM $tbl_name WHERE ProductName= searchfield; > <select name="cat"> <option value="cd" selected="selected" >CD</option> <option value="dvd" >DVD</option> <option value="game" >GAME</option> </select> <form name="ex2" method="get" action="/searchresults.php"> <input type="text" name="searchfield" size="22" maxlength="40" id="srchdrop" /> <input type="submit" value="Search Now! »" id="gosrch" /> </td></tr> </form> [code] [/code]
  6. No that still brings up the error Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\MainPage\login.php:5) in C:\xampp\htdocs\MainPage\login.php on line 301 Plus my form doesnt appear again line303 is: header("Location: ../MainPage/first.php"); The start of first.php <?PHP if (isset($_SESSION['usertype']) && $_SESSION['usertype'] == 1) { echo "You're logged in"; } else { echo "You must be logged in"; } ?>
  7. Im setting up a login page with redirection but im getting the following error Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\MainPage\login.php:5) in C:\xampp\htdocs\MainPage\login.php on line 305 Line 305 is: header("Location: ../MainPage/first.php"); My php for my login.php looks like this <?php include("adminconnect.php"); $tbl_name="adminusers"; if(isset($_POST['uname']) && isset($_POST['pword'])) { // Define $myusername and $mypassword $uname=mysql_escape_string($_POST['uname']); $pword=mysql_escape_string($_POST['pword']); $sql="SELECT * FROM $tbl_name WHERE username='$uname' and password='$pword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row /* grab the usertype */ $r = mysql_fetch_array($result); /* We will verify that the num_rows exists, for some reason you weren'y verifying this */ /* After verifying, we will then set the session, this is assuming that there is a column */ /* in your table named 'type' and its value is either '1' or '2' */ if ($count > 0) { $_SESSION['usertype'] = $r['usertype']; $logged = true; } else { echo "Wrong Username/Pad =ssword."; } if ($_SESSION['usertype'] == "2" && $logged == "true") { header("Location: ../Admin_files/start.php"); } else if ($_SESSION['usertype'] == "1" && $logged == "true") { header("Location: ../MainPage/first.php"); } } ?> <form action="../MainPage/login.php" method="POST"> <div align="right">Pleas enter your Login Name</b> <BR>(This is the name you signed up with)</div> </td> <td width="50%"> <input type="text" name="uname" size="12" maxlength="50" class="field"> </td> </tr> <tr> <td class="bgrl"> <div align="right">Please enter your <b>password</b></div> </td> <td width="50%" class="bgrl"> <input type="password" name="pword" size="18" class="field"> </td> </tr> <tr><td> </td> <td> <input type="submit" value="Login »" class="submit"></form></td> </tr> <tr><td colspan="2" class="genericside"><span class="t11bw">Forgotten your password?</span></td> </tr> <tr valign="top"> <td class="alignright"> <form name="passwordreminder" action="/member_login.php" method="post"> <input type="hidden" name="type" value="passwordreminder"> Please enter your email here:</td> <td><input type="text" name="reminderemail" class="field" maxlength="50"><br> <input type="submit" value="Send Password »" class="submit"> </form>
  8. Ive changed the name to MainPage as suggested but im still getting the same problem with the page just refreshing The top of the page login.php looks like this <?php session_start();?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> the php looks like this now <?php include("adminconnect.php"); $tbl_name="adminusers"; if(isset($_POST['uname']) && isset($_POST['pword'])) { // Define $myusername and $mypassword $uname=mysql_escape_string($_POST['uname']); $pword=mysql_escape_string($_POST['pword']); $sql="SELECT * FROM $tbl_name WHERE username='$uname' and password='$pword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row /* grab the usertype */ $r = mysql_fetch_array($result); /* We will verify that the num_rows exists, for some reason you weren'y verifying this */ /* After verifying, we will then set the session, this is assuming that there is a column */ /* in your table named 'type' and its value is either '1' or '2' */ if ($count > 0) { $_SESSION['usertype'] = $r['usertype']; $logged = true; } else { echo "Wrong Username/Pad =ssword."; } if ($_SESSION['usertype'] == "2" && $logged == "true") { header("Location: ../Admin_files/start.php"); } else if ($_SESSION['usertype'] == "1" && $logged == "true") { header("Location: ../MainPage/first.php"); } } ?> <form action="login.php" method="POST"> <div align="right">Pleas enter your Login Name</b> <BR>(This is the name you signed up with)</div> </td> <td width="50%"> <input type="text" name="uname" size="12" maxlength="50" class="field"> </td> </tr> <tr> <td class="bgrl"> <div align="right">Please enter your <b>password</b></div> </td> <td width="50%" class="bgrl"> <input type="password" name="pword" size="18" class="field"> </td> </tr> <tr><td> </td> <td> <input type="submit" value="Login »" class="submit"></form></td> </tr> <tr><td colspan="2" class="genericside"><span class="t11bw">Forgotten your password?</span></td> </tr> <tr valign="top"> <td class="alignright"> <form name="passwordreminder" action="/member_login.php" method="post"> <input type="hidden" name="type" value="passwordreminder"> Please enter your email here:</td> <td><input type="text" name="reminderemail" class="field" maxlength="50"><br> <input type="submit" value="Send Password »" class="submit"> </form>
  9. Getting the error Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\Main Page\login.php:5) in C:\xampp\htdocs\Main Page\login.php on line 306 Line 306 is : header("Location: ../Main Page/first.php") <?php include("adminconnect.php"); $tbl_name="adminusers"; if(isset($_POST['uname']) && isset($_POST['pword'])) { // Define $myusername and $mypassword $uname=mysql_escape_string($_POST['uname']); $pword=mysql_escape_string($_POST['pword']); $sql="SELECT * FROM $tbl_name WHERE username='$uname' and password='$pword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row /* grab the usertype */ $r = mysql_fetch_array($result); /* We will verify that the num_rows exists, for some reason you weren'y verifying this */ /* After verifying, we will then set the session, this is assuming that there is a column */ /* in your table named 'type' and its value is either '1' or '2' */ if ($count > 0) { $_SESSION['usertype'] = $r['usertype']; $logged = true; } else { echo "Wrong Username/Pad =ssword."; } if ($_SESSION['usertype'] == "2" && $logged == "true") { header("Location: ../Admin_files/start.php"); } else if ($_SESSION['usertype'] == "1" && $logged == "true") { header("Location: ../Main Page/first.php"); } } ?> <form action="login.php" method="POST"> <div align="right">Pleas enter your Login Name</b> <BR>(This is the name you signed up with)</div> </td> <td width="50%"> <input type="text" name="uname" size="12" maxlength="50" class="field"> </td> </tr> <tr> <td class="bgrl"> <div align="right">Please enter your <b>password</b></div> </td> <td width="50%" class="bgrl"> <input type="password" name="pword" size="18" class="field"> </td> </tr> <tr><td> </td> <td> <input type="submit" value="Login »" class="submit"></form></td> </tr> <tr><td colspan="2" class="genericside"><span class="t11bw">Forgotten your password?</span></td> </tr> <tr valign="top"> <td class="alignright"> <form name="passwordreminder" action="/member_login.php" method="post"> <input type="hidden" name="type" value="passwordreminder"> Please enter your email here:</td> <td><input type="text" name="reminderemail" class="field" maxlength="50"><br> <input type="submit" value="Send Password »" class="submit"> </form>
  10. So $_SESSION['type'] = $r['usertype']; should be $_SESSION['usertype'] = $r['usertype']; ???
  11. No my page still doesnt go anywhere, just refreshes!!! <?php session_start(); include("adminconnect.php"); $tbl_name="adminusers"; if(isset($_POST['uname']) && isset($_POST['pword'])) { // Define $myusername and $mypassword $uname=mysql_escape_string($_POST['uname']); $pword=mysql_escape_string($_POST['pword']); $sql="SELECT * FROM $tbl_name WHERE username='$uname' and password='$pword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row /* grab the usertype */ $r = mysql_fetch_array($result); /* We will verify that the num_rows exists, for some reason you weren'y verifying this */ /* After verifying, we will then set the session, this is assuming that there is a column */ /* in your table named 'type' and its value is either '1' or '2' */ if ($count > 0) { $_SESSION['type'] = $r['usertype']; $logged = true; } else { echo "Wrong Username/Pad =ssword."; } if ($_SESSION['usertype'] == "2" && $logged == "true") { header("Location: ../Admin_files/start.php"); } else if ($_SESSION['usertype'] == "1" && $logged == "true") { header("Location: ../Main Page/first.php"); } } ?> <form action="login.php" method="POST"> <div align="right">Pleas enter your Login Name</b> <BR>(This is the name you signed up with)</div> </td> <td width="50%"> <input type="text" name="uname" size="12" maxlength="50" class="field"> </td> </tr> <tr> <td class="bgrl"> <div align="right">Please enter your <b>password</b></div> </td> <td width="50%" class="bgrl"> <input type="password" name="pword" size="18" class="field"> </td> </tr> <tr><td> </td> <td> <input type="submit" value="Login »" class="submit"></form></td> </tr> <tr><td colspan="2" class="genericside"><span class="t11bw">Forgotten your password?</span></td> </tr> <tr valign="top"> <td class="alignright"> <form name="passwordreminder" action="/member_login.php" method="post"> <input type="hidden" name="type" value="passwordreminder"> Please enter your email here:</td> <td><input type="text" name="reminderemail" class="field" maxlength="50"><br> <input type="submit" value="Send Password »" class="submit"> </form>
  12. Sorry Sasa, What do you mean? Im a session noob as you can tell!
  13. My code still doesnt redirect to the pages but only to itself!!! for example my tables look like this CREATE TABLE `adminusers` ( `name` varchar(255) collate latin1_general_ci default NULL, `address` varchar(255) collate latin1_general_ci default NULL, `address1` varchar(255) collate latin1_general_ci default NULL, `address2` varchar(255) collate latin1_general_ci default NULL, `address3` varchar(255) collate latin1_general_ci default NULL, `address4` varchar(255) collate latin1_general_ci default NULL, `county` varchar(255) collate latin1_general_ci default NULL, `zip` varchar(255) collate latin1_general_ci default NULL, `telephone` decimal(10,0) default NULL, `email` varchar(255) collate latin1_general_ci default NULL, `username` varchar(255) collate latin1_general_ci default NULL, `password` varchar(255) collate latin1_general_ci default NULL, `usertype` decimal(10,0) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; -- ---------------------------- -- Records -- ---------------------------- INSERT INTO `adminusers` VALUES ('', '23 Ashville', 'Athy', 'Co Kildare', 'Ashville', 'Ashville', 'Kildae', '900210', '9999999999', 'yrne000@hotmail.com', 'Mikebyrne000', 'gerrard000', '2'); INSERT INTO `adminusers` VALUES ('Me', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx', 'xxx', '777777', 'ghghhg', 'user', 'user', '1'); I login with user user and expect the page First.php to come up My code is <?php session_start(); include("adminconnect.php"); $tbl_name="adminusers"; if(isset($_POST['uname']) && isset($_POST['pword'])) { // Define $myusername and $mypassword $uname=mysql_escape_string($_POST['uname']); $pword=mysql_escape_string($_POST['pword']); $sql="SELECT * FROM $tbl_name WHERE username='$uname' and password='$pword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row /* grab the usertype */ $r = mysql_fetch_array($result); /* We will verify that the num_rows exists, for some reason you weren'y verifying this */ /* After verifying, we will then set the session, this is assuming that there is a column */ /* in your table named 'type' and its value is either '1' or '2' */ if ($count > 0) { $_SESSION['type'] = $r['usertype']; $logged = true; } else { echo "Wrong Username/Pad =ssword."; } if ($_SESSION['usertype'] === "2" && $logged == true) //remove '' { header("Location: ../Admin_files/start.php"); } else if ($_SESSION['usertype'] === "1" && $logged == true) // ad $ and remove '' { header("Location: ../Main Page/first.php"); } } ?> <form action="login.php" method="POST"> <div align="right">Pleas enter your Login Name</b> <BR>(This is the name you signed up with)</div> </td> <td width="50%"> <input type="text" name="uname" size="12" maxlength="50" class="field"> </td> </tr> <tr> <td class="bgrl"> <div align="right">Please enter your <b>password</b></div> </td> <td width="50%" class="bgrl"> <input type="password" name="pword" size="18" class="field"> </td> </tr> <tr><td> </td> <td> <input type="submit" value="Login »" class="submit"></form></td> </tr> <tr><td colspan="2" class="genericside"><span class="t11bw">Forgotten your password?</span></td> </tr> <tr valign="top"> <td class="alignright"> <form name="passwordreminder" action="/member_login.php" method="post"> <input type="hidden" name="type" value="passwordreminder"> Please enter your email here:</td> <td><input type="text" name="reminderemail" class="field" maxlength="50"><br> <input type="submit" value="Send Password »" class="submit"> </form>
  14. My form just seems to refresh itself as opposed to redirecting to the correct page <?php session_start(); include("adminconnect.php"); $tbl_name="adminusers"; if(isset($_POST['uname']) && isset($_POST['pword'])) { // Define $myusername and $mypassword $uname=mysql_escape_string($_POST['uname']); $pword=mysql_escape_string($_POST['pword']); $sql="SELECT * FROM $tbl_name WHERE username='$uname' and password='$pword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row /* grab the usertype */ $r = mysql_fetch_array($result); /* We will verify that the num_rows exists, for some reason you weren'y verifying this */ /* After verifying, we will then set the session, this is assuming that there is a column */ /* in your table named 'type' and its value is either '1' or '2' */ if ($count > 0) { $_SESSION['type'] = $r['usertype']; $logged = true; } else { echo "Wrong Username/Pad =ssword."; } if ($_SESSION['usertype'] == "2" && $logged == 'true') { header("Location: ../Admin_files/start.php"); } else if ($_SESSION['usertype'] == "1" && logged == 'true') { header("Location: ../Main Page/first.php"); } } ?> <form action="login.php" method="POST"> <div align="right">Pleas enter your Login Name</b> <BR>(This is the name you signed up with)</div> </td> <td width="50%"> <input type="text" name="uname" size="12" maxlength="50" class="field"> </td> </tr> <tr> <td class="bgrl"> <div align="right">Please enter your <b>password</b></div> </td> <td width="50%" class="bgrl"> <input type="password" name="pword" size="18" class="field"> </td> </tr> <tr><td> </td> <td> <input type="submit" value="Login »" class="submit"></form></td> </tr> <tr><td colspan="2" class="genericside"><span class="t11bw">Forgotten your password?</span></td> </tr> <tr valign="top"> <td class="alignright"> <form name="passwordreminder" action="/member_login.php" method="post"> <input type="hidden" name="type" value="passwordreminder"> Please enter your email here:</td> <td><input type="text" name="reminderemail" class="field" maxlength="50"><br> <input type="submit" value="Send Password »" class="submit"> </form>
  15. Im getting the error Parse error: syntax error, unexpected '=' in C:\xampp\htdocs\Main Page\login.php on line 303 line 303 is: else if ($_SESSION['usertype'] == "1" && logged = 'true') my php so far <?php session_start(); include("adminconnect.php"); $tbl_name="adminusers"; if(isset($_POST['uname']) && isset($_POST['pword'])) { // Define $myusername and $mypassword $uname=mysql_escape_string($_POST['uname']); $pword=mysql_escape_string($_POST['pword']); $sql="SELECT * FROM $tbl_name WHERE username='$uname' and password='$pword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row /* grab the usertype */ $r = mysql_fetch_array($result); /* We will verify that the num_rows exists, for some reason you weren'y verifying this */ /* After verifying, we will then set the session, this is assuming that there is a column */ /* in your table named 'type' and its value is either '1' or '2' */ if ($count > 0) { $_SESSION['type'] = $r['usertype']; $logged = true; } else { echo "Wrong Username/Password."; } if ($_SESSION['usertype'] == "2" && $logged = 'true') { header("Location: ../Admin_files/start.php"); } else if ($_SESSION['usertype'] == "1" && logged = 'true') { header("Location: ../Main Page/first.php"); } } ?>
  16. Im getting the error Parse error: syntax error, unexpected '=' in C:\xampp\htdocs\Main Page\login.php on line 303 line 303 is: else if ($_SESSION['usertype'] == "1" && logged = 'true') my php so far <?php session_start(); include("adminconnect.php"); $tbl_name="adminusers"; if(isset($_POST['uname']) && isset($_POST['pword'])) { // Define $myusername and $mypassword $uname=mysql_escape_string($_POST['uname']); $pword=mysql_escape_string($_POST['pword']); $sql="SELECT * FROM $tbl_name WHERE username='$uname' and password='$pword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row /* grab the usertype */ $r = mysql_fetch_array($result); /* We will verify that the num_rows exists, for some reason you weren'y verifying this */ /* After verifying, we will then set the session, this is assuming that there is a column */ /* in your table named 'type' and its value is either '1' or '2' */ if ($count > 0) { $_SESSION['type'] = $r['usertype']; $logged = true; } else { echo "Wrong Username/Password."; } if ($_SESSION['usertype'] == "2" && $logged = 'true') { header("Location: ../Admin_files/start.php"); } else if ($_SESSION['usertype'] == "1" && logged = 'true') { header("Location: ../Main Page/first.php"); } } ?>
  17. Yeah, the 3 fields in the database im looking at are password, username and usertype
  18. Should I be setting a session varible for $_SESSION['usertype']?? Could that be the problem?
  19. <?php include("adminconnect.php"); $tbl_name="adminusers"; if(isset($_POST['uname']) && isset($_POST['pword'])) { session_start(); // Define $myusername and $mypassword $uname=mysql_escape_string($_POST['uname']); $pword=mysql_escape_string($_POST['pword']); $sql="SELECT * FROM $tbl_name WHERE username='$uname' and password='$pword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if ($_SESSION['usertype'] == "2") { header("Location: ../admin_files/start.php"); } else if ($_SESSION['usertype'] == "1") { header("Location: ../Main Page/first.php"); } } ?> <form action="login.php" method="POST"> <div align="right">Pleas enter your Login Name</b> <BR>(This is the name you signed up with)</div> </td> <td width="50%"> <input type="text" name="uname" size="12" maxlength="50" class="field"> </td> </tr> <tr> <td class="bgrl"> <div align="right">Please enter your <b>password</b></div> </td> <td width="50%" class="bgrl"> <input type="password" name="pword" size="18" class="field"> </td> </tr> <tr><td> </td> <td> <input type="submit" value="Login »" class="submit"></form></td> </tr> <tr><td colspan="2" class="genericside"><span class="t11bw">Forgotten your password?</span></td> </tr> <tr valign="top"> <td class="alignright"> <form name="passwordreminder" action="/member_login.php" method="post"> <input type="hidden" name="type" value="passwordreminder"> Please enter your email here:</td> <td><input type="text" name="reminderemail" class="field" maxlength="50"><br> <input type="submit" value="Send Password »" class="submit"> </form>
  20. Thats fixed the error but the page returns to Login.php (the page its on) when I enter in the details rather than start.php or first.php
  21. Im getting the error Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\Main Page\login.php:5) in C:\xampp\htdocs\Main Page\login.php on line 10 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\Main Page\login.php:5) in C:\xampp\htdocs\Main Page\login.php on line 10 Line 10 refers to: <?php session_start();?> My code up to line 10 looks like <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>CD WOW! - CD - DVD - GAMES | Best Prices & FREE Delivery Worldwide!</title><meta name="description" content="CD WOW! CDs, DVDs & Games at unbeatable prices with FREE delivery worldwide. www.cdwow.ie" /><meta name="keywords" content="cd's, cds, cheapest, music, cd, dvd, games, buy, free delivery, ireland, shop, bargain, low price, low, price, cheapest, cheap, gift" /> <link rel="stylesheet" type="text/css" href="../Main Page/style_main.css"> <link rel="stylesheet" type="text/css" href="../Main Page/style_1.css" title="stylesheet"> <?php session_start();?>
  22. Would that be if ($_SESSION['type'] == "2") { header("Location: ../admin_files/start.php"); } else if ($_SESSION['type'] == "1") { header("Location: ../Main Page/first.php"); } or if ($_SESSION['usertype'] == "2") { header("Location: ../admin_files/start.php"); } else if ($_SESSION['usertype'] == "1") { header("Location: ../Main Page/first.php"); }
  23. Ok my code looks like this now <?php include("adminconnect.php"); $tbl_name="adminusers"; if(isset($_POST['uname']) && isset($_POST['pword'])) { session_start(); // Define $myusername and $mypassword $uname=mysql_escape_string($_POST['uname']); $pword=mysql_escape_string($_POST['pword']); $sql="SELECT * FROM $tbl_name WHERE username='$uname' and password='$pword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if ($_SESSION['type'] == "Emp") { header("Location: ../admin_files/start.php"); } else if ($_SESSION['type'] == "Cust") { header("Location: ../Main Page/first.php"); } ?> I'm a little confused as to how the code tells what type of user it as as my "user" field only has two values 1 or 2 to tell the usertype
  24. I want to setup some login redirection on my page. My database is setup so that employees are assigned "2" on registration and customers "1". The is is stored in the field usertype. If an Employee logs on I want them to be redirected to ../Admin_files/start.php and the customers to be redirected to ../Main Page/first At present my code looks like this <?php include("adminconnect.php"); $tbl_name="adminusers"; if(isset($_POST['uname']) && isset($_POST['pword'])) { session_start(); // Define $myusername and $mypassword $uname=mysql_escape_string($_POST['uname']); $pword=mysql_escape_string($_POST['pword']); $sql="SELECT * FROM $tbl_name WHERE username='$uname' and password='$pword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1) { while($row = mysql_fetch_assoc($result)) { // Register $myusername, $mypassword and redirect to file "login_success.php" $_SESSION['uname'] = $row['username']; $_SESSION['pword'] = $row['password']; //The : acts as a Else. So if row user =1 then its a Cust, otherwise it's a Emp. $_SESSION['type'] = ($row['User']==1)?"Cust":"Emp"; header("Location: ../admin_files/start.php.php"); } }else{ echo "Wrong Username or Password"; } } ?> <form action="login.php" method="POST"> <div align="right">Pleas enter your Login Name</b> <BR>(This is the name you signed up with)</div> </td> <td width="50%"> <input type="text" name="uname" size="12" maxlength="50" class="field"> </td> </tr> <tr> <td class="bgrl"> <div align="right">Please enter your <b>password</b></div> </td> <td width="50%" class="bgrl"> <input type="password" name="pword" size="18" class="field"> </td> </tr> <tr><td> </td> <td> <input type="submit" value="Login »" class="submit"></form></td> </tr>
×
×
  • 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.