My corp login page contains the info you guys mentioned. Problem is when running this code I just want it to go to the corparea.php file. I do not want that page to do anything special, it will only have info on there. I have changed my table name to onlineoffers but as I say I am not looking for it to bring back any data from there only check the username and password fields.
<?php
$host="LOCALHOST"; // Host name
$username="USERNAME"; // Mysql username
$password="PASSWORD"; // Mysql password
$db_name="DBNAME"; // Database name
$tbl_name="table1"; // Table name
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = sha1($myusername);
$mypassword = sha1($mypassword);
$sql = "SELECT * FROM `onlineoffers` WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
$_SESSION['myusername'] = $myusername;
$_SESSION['mypassword'] = $mypassword;
header("location:corparea.php");
}
else {
echo "Wrong Username or Password";
}
?>
I then want to create a seperate page off the corparea.php page when that script is ran it will then select the info from the exact same table and return it to corpupdate.php in a form so it can be edited and saved.
So to clarify the username and passwords are stored in onlineoffers and also in there is more info. I want it so when they click the update personal details link it will remember who they are logged in as and return the requied info from the table i.e. return name, description, conditions.
What I have so far for corpupdate.php
<?php
$host="LOCALHOST"; // Host name
$username="USERNAME"; // Mysql username
$password="PASSWORD"; // Mysql password
$db_name="DBNAME"; // Database name
$tbl_name="table1"; // Table name
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql = "SELECT description promotion conditions offercode FROM `onlineoffers` WHERE `username='$myusername' and password='$mypassword' LIMIT 1";
$result = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_row($result)) {
list( $username, $password, $Name, $Registration_Number, $Contact_Number ) = $row;
if(($myusername == $username) && ($mypassword == $password)) {
$_SESSION['myusername'] = $username;
$_SESSION['mypassword'] = $password;
$description = $description;
$promotion = $promotion;
$conditions = $conditions;
$offercode = $offercode;
}
?>
so my table it onlineoffers
my data I want to bring back from the table is description, promotion, conditions, offercode (and nothing else) I then want to lay that out on top of each other as shown in my first code in an editable form. I think the code so far should get the correct code but I need to place it in a form...
I will then add an update button which will update the DB with the new text. Just for info the password is "password" in the DB and username "username" and all the info I want is in the same table.