Okay. I had never even looked at PHP or MySQL until yesterday. I need to write a cgi script, so I've given myself a crash course.
I'm trying to make an email login page. I want to create a simple login page where the user puts in his userid and password and checks a box whether he wants his email to open in a new window (if left unchecked it will open in that same window). I then want to pass the userid and password to a php script in the cgi bin that will check the userid and password against a table in a MySQL database. If a match is found, the script will extract the data in field "interface". This data is just a flag. Some of the users to the website will have one email interface, some will have a different one. (Right now I'm just using "1" for interface 1 and "2" for interface 2. ) Once the script pulls out the data from this field, it will run three "if - then" statements:
If there was no match at all, tell the user that login was invalid.
If there was a match and if interface=1, then redirect to a certain url while passing along username, password.
If there was a match and if interface=2, then redirect to a different url while passing along username, password, (and some other data).
I have the form created. I've created the table in MySQL just fine. The database is "email" and the table is "login".
What I need help with is the cgi script. I'll post what I've written so far (please don't laugh, remember I'm a tender newbie):
//set variables
$userid = ($POST['userid']);
$password = ($POST['password']);
$result = 0;
$mail_one = "http://webmail.first_location.com";
$mail_two = "http://webmail.second_location.com";
//connect to database
$db = mysql_connect("localhost","username","password");
mysql_select_db("email",$db);
$result = mysql_query("SELECT interface FROM login WHERE userid=$userid AND password=$password", $db);
if ($result = 0) {
//inform user that login what invalid
//I don't know what to do here
if ($result = 1) {
$URL="http://webmail.first_location.com/src/redirect.php?login_username=$userid&secretkey=$password&just_logged_in=1
";
}
if ($result = 2) {
//I haven't done this yet
So, this is what I have. If anyone has any suggestions for me on what to do, I'd appreciate it very much. Believe it or not, this little script (probably full of errors) has taken me hours to create. My main problem is that I just don't know the commands or syntax. I know that I should probably hire someone to write this for me, but I'm poor, so I'm here begging for help.
Thanks for taking the time to read this and thank you in advance for replying.