View Full Version : php/mysql getting started
Bouley86
02-22-2003, 04:53 PM
Ok, I am somewhat familiar with PHP now but MySQL is completely new to me. I have phpMyAdmin installed on my server. What I'm trying to do is create a script using a MySQL database. What I want to happen is when someone registers it puts the information onto the db and sends the person an email. In the email is a link to a page that will retrieve the information that was added to the db and validate it before the user can log in. So let's say you go to my site and sign up. You're sent an email that has a link to something like new.php?mode=confirm&id=23094 where the id number is your user specific ID instead of being identified by an actual name. When the page loads it also creates your account so you are now able to login. I have a script set up now that doesn't make you confirm your account before gaining access to the users area and eacch user is identified by a username not a number so all the names are case sensitive and i don't like that. Get it? Cuz I just confused the hell outta myself. But basically I just need some basic information to get myself started with using MySQL and phpMyAdmin.
scoutt
02-23-2003, 04:19 PM
so did you search for anything tha twill tell you how to use mysql?
mysql is very easy, a lot easier than php. look into the php manual and the mysql manual. you will want to make a connection to mysql in php so you need to look up mysql_connect() and mysql_select_db()
then to insert you look up insert() and to select the info from the db you look into select().
again if you didn't search I told you I have a lot of tutorials
http://www.snippetlibrary.com/tutorials.php?kid=11&catname=Databases
when you enter the user info into the db you will want to make 1 field the field you check to see if they confirmed or not. I would set this field to 2 when they first sign up, then if they confirm change it to 1 and then you know they are active and a member.
Bouley86
02-23-2003, 09:03 PM
alrite..i think im starting to understand this better but im still having problems figuring stuff out. now dont think im asking you to write an entire script for me im asking for help. I understand how to connect and select a database. No questions there. But now here's an example. Let's say there's a form to sign up. We'll call the name field $name , the password field $pass , and the email field $email. When the person submits the form I want it to go to a table and we'll say that this is the first person to register, so I want their ID to be 1 and I want all the information mentioned ($name, $email, and $pass) entered into the table. I also want a timestamp put into the table so we know when they first submitted the form. Now when they check their email there is a link to profile.php?mode=confirm&id=1 and when they go to this page it connects to mysql and goes to the row that has the id 1 in it. Then I want it to check the timestamp and if it has been less than 5 days I want them to be allowed to complete their registration using the $pass and $name that were entered earlier. If you can tell me how to do this then I can figure the rest out on my own because there is other stuff that I wanna try and do. I just don't understand how to do the above (and I don't understand how phpMyAdmin ties into it all..)
Bouley86
02-23-2003, 09:44 PM
OMG IM SO HAPPY RITE NOW!! I got my form to work with the mysql and everything OMG OMG OMG OMG OMG!!!!! HAHA
scoutt
02-23-2003, 09:51 PM
phpmyadmin is just a tool to look at the db, you could use it for more but why. so phpmyadmin is to make tables and columns in the table and see the status of the tables and export and import. that is all.
first you use phpmyadmin to make a table. then inside this table you want 5 fields
id set to auto_increment and primary
name set as varchar(100)
pass set as the same
email set as the same
time_stamp set as the same
status set as tinyint(2)
so when they click on submit for the first sign up you want to insert the info to the db.
//a fter you connect to the db
$insert = mysql_query("INSERT INTO table_name (id,name,pass,email,time_stamp,status)
VALUES ('','{$_POST["name"]}','{$_POST["pass"]}','{$_POST["email"]}','".time()."','2')");
$last_id = mysql_insert_id($insert);
now see that I listed the column names first (red) and then the values (blue) and teh forms posted values (bold blue).
that will insert the stuff into the db then you need to send the email using email().
also see how I inserted status to 2. and I used a function from mysql to get the last id of the last insert. when you send the email the link will be
profile.php?mode=confirm&id=$id
so then when they go to tha tlink you select the id from the url against the db.
// check to see if mode is set.
if($_GET["mode"] == "confirm"){
// select the user info form the db
$select = mysql_query("select * from table_name where id = '{$_GET["id"]}'");
// if one is found let it through
if(mysql_num_rows($select)){
// fecth the ifno from the db if the id form the url matches
$row = mysql_fetch_array($select);
// do the math to find out if the user waited to long or not
if ($row["time_stamp"] < 5days in seconds){
// also do time stamp check here
// do the form here so they can login
// have a hidden field to insert the id in the form
// name the hidden field
} else {
// do stuff here if not found, like show them a
// register link
}
}
now when they login again you need to update the db to set the status to 1
// connect to db
// and update the users status according to the id in the form
$update = mysql_query("update table_name set status='1' where id = '{$_POST["id"]}'");
// the rest of the page
see how easy it is. I toldyou want to look at and gave you pages to look at. just takes a little reading to get it done.
does this help some?
Bouley86
02-23-2003, 10:37 PM
alrite..the only thing im not getting rite now is when i send the email i have a linke to profile.php?mode=confirm&id=$id but how does it know what to put in the variable $id? Because im registering with test users and it just comes with id= and nothing there..
scoutt
02-23-2003, 11:06 PM
sorry it should be
profile.php?mode=confirm&id=$last_id
Bouley86
02-24-2003, 12:03 AM
hmm..still didn't work..this is what i have:
$db = mysql_connect("localhost", "bouley86", "****");
mysql_select_db("profiledb",$db);
$insert = mysql_query("INSERT INTO users (id,sn,pass,email,time_stamp,status)
VALUES ('','{$_POST["sn"]}','{$_POST["pass"]}','{$_POST["email"]}','".time()."','2')");
$last_id = mysql_insert_id($insert);
mail("$email" , "Bouley86.com Profile Registration" , "This email is to confirm your registration at Bouley86.com Profiles.
If you did not sign up for this service or you no longer wish to have the account created, ignore this email.
If you want your account to be made click the link below.
Your information will be set up as follows - \r\n
Username: $sn\r\n
Password: $pass\r\n
If this is not the information you want to be set up go back to http://profiles.bouley86.com and send the form again.\r\n
http://profiles.bouley86.com/profile.php?mode=confirm&id=$last_id\r\n\r\n
Thank you for choosing Bouley86.com Profiles!", "From: Bouley86.com Profiles <profiles@bouley86.com>\r\n");
scoutt
02-24-2003, 12:09 AM
hmm I see 2 spots where there is no variable.
profile.php?mode=confirm&id=" target="_blank">http://profiles.bouley86.com/profil...ode=confirm&id=</a>$last_id\r\n\r\nThank
also there is no reason to use a target in an email, it will default to open there browser anyway.
also it is better to have all that info you have int he mail function in variables.
Bouley86
02-24-2003, 06:39 AM
yeah tha's weird cuz tha's not what i posted..the code in my file doesnt have the <a href> tag its just a link starting with http://
scoutt
02-24-2003, 09:16 AM
ok I fixed it and that is what it should look like. if you still don't get the $last_id then make sure the info is gettting inserted into the db correctly. that is where phpmyadmin comes in. when you do goto myadmin export the table and post the code it gives here, I just want the structure and no data.
so it will look something like this
create tablename (
id blah blah
name blah blah
...
)
Bouley86
02-24-2003, 03:00 PM
yeah what you changed it to is what i have and it's not puttin the id in the table..so here's what i got:
CREATE TABLE users (
id int(11) NOT NULL auto_increment,
sn varchar(100) NOT NULL default '',
pass varchar(100) NOT NULL default '',
email varchar(100) NOT NULL default '',
time_stamp varchar(100) NOT NULL default '',
status tinyint(2) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM;
scoutt
02-24-2003, 03:06 PM
ahh use this instead
$last_id = mysql_insert_id();
Bouley86
02-24-2003, 03:11 PM
that did the trick...now i gotta gotta put all the stuff in profile.php..thanks for the help..
Bouley86
02-24-2003, 03:39 PM
ok...now i've edited my profile.php page and now it's just coming up blank..wha's wrong?
<?
include("settings.php");
if (isset($mode)) {
if ($mode == "confirm") {
$db = mysql_connect("localhost", "bouley86", "****");
mysql_select_db("profiledb",$db);
$select = mysql_query("select * from users where id = '{$_GET["id"]}'");
if(mysql_num_rows($select)){
$row = mysql_fetch_array($select);
$now = time()
if ($now - $row["time_stamp"] < 432000){
echo "<head><style type='text/css'>
<!--
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: underline}
A:hover {text-decoration: underline}
-->
</style>
<style type='text/css'>
A:link {color: #000000;}
A:visited {color: #000000;}
A:hover {color: #000000;}
</style><title>Bouley86.com Profiles: Confirmation</title></head><body><center><font face='Arial'><p>Your Confirmation is now complete. You can use the form below to log in.</p><center>
<form action="profile.php?mode=login" method="post">
<table>
<tr>
<td><font face='Arial'>Name: </td>
<td><input type=text name=sn></td>
</tr>
<tr>
<td><font face='Arial'>Password: </td>
<td><input type=password name=pass></td>
</tr>
</table>
<p><input type="submit" value="Login"></p>
</form></center>";
} else {
<head><style type='text/css'>
<!--
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: underline}
A:hover {text-decoration: underline}
-->
</style>
<style type='text/css'>
A:link {color: #000000;}
A:visited {color: #000000;}
A:hover {color: #000000;}
</style><title>Bouley86.com Profiles: Confirmation</title></head><body><center><font face='Arial'>Either you've reached this page by error or you waited longer than 5 days before you registered. Please sign up again.</center>";
}
}
echo
} elseif ($mode == "login") {
if ((isset($sn)) && (isset($pass))) {
if (($sn != "") && ($pass != "")) {
$dir = "$userpath/$sn";
include("$dir/pass.php");
if ($pass == $mypass) {
// SHOW THE SCREEN
include("mods.php");
} else {
echo "<head><style type='text/css'>
<!--
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: underline}
A:hover {text-decoration: underline}
-->
</style>
<style type='text/css'>
A:link {color: #000000;}
A:visited {color: #000000;}
A:hover {color: #000000;}
</style><title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Incorrect login.</p></center>";
}
} else {
echo "<head><style type='text/css'>
<!--
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: underline}
A:hover {text-decoration: underline}
-->
</style>
<style type='text/css'>
A:link {color: #000000;}
A:visited {color: #000000;}
A:hover {color: #000000;}
</style><title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Incorrect login.</p></center>";
}
} else {
echo "<head><style type='text/css'>
<!--
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: underline}
A:hover {text-decoration: underline}
-->
</style>
<style type='text/css'>
A:link {color: #000000;}
A:visited {color: #000000;}
A:hover {color: #000000;}
</style><title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Username and/or password not entered.</p></center>";
}
} elseif ($mode = "update") {
echo "<font face='Arial'><center><b><p>Update mode.</p></b>";
$dir = "$userpath/$sn";
$cnf = fopen("$dir/config.php","w+");
$maintext = stripslashes(htmlspecialchars($maintext));
$spcontent1 = stripslashes(htmlspecialchars($spcontent1));
$spcontent2 = stripslashes(htmlspecialchars($spcontent2));
$spcontent3 = stripslashes(htmlspecialchars($spcontent3));
$spcontent4 = stripslashes(htmlspecialchars($spcontent4));
$spcontent5 = stripslashes(htmlspecialchars($spcontent5));
$sptitle1 = stripslashes(htmlspecialchars($sptitle1));
$sptitle2 = stripslashes(htmlspecialchars($sptitle2));
$sptitle3 = stripslashes(htmlspecialchars($sptitle3));
$sptitle4 = stripslashes(htmlspecialchars($sptitle4));
$sptitle5 = stripslashes(htmlspecialchars($sptitle5));
fputs($cnf,"<? ");
fputs($cnf,"\$sn=\"$sn\"; ");
fputs($cnf,"\$ip=\"$REMOTE_ADDR\"; ");
fputs($cnf,"\$font=\"$font\"; \$colortext=\"$colortext\"; ");
fputs($cnf,"\$colorback=\"$colorback\"; \$colorlink=\"$colorlink\"; ");
fputs($cnf,"\$coloralink=\"$coloralink\"; \$colorvlink=\"$colorvlink\"; ");
fputs($cnf,"\$maintext=\"$maintext\"; ");
fputs($cnf,"\$sptitle1=\"$sptitle1\"; \$spcontent1=\"$spcontent1\"; ");
fputs($cnf,"\$sptitle2=\"$sptitle2\"; \$spcontent2=\"$spcontent2\"; ");
fputs($cnf,"\$sptitle3=\"$sptitle3\"; \$spcontent3=\"$spcontent3\"; ");
fputs($cnf,"\$sptitle4=\"$sptitle4\"; \$spcontent4=\"$spcontent4\"; ");
fputs($cnf,"\$sptitle5=\"$sptitle5\"; \$spcontent5=\"$spcontent5\"; ");
fputs($cnf,"\$linktitle1=\"$linktitle1\"; \$linkurl1=\"$linkurl1\"; ");
fputs($cnf,"\$linktitle2=\"$linktitle2\"; \$linkurl2=\"$linkurl2\"; ");
fputs($cnf,"\$linktitle3=\"$linktitle3\"; \$linkurl3=\"$linkurl3\"; ");
fputs($cnf,"\$linktitle4=\"$linktitle4\"; \$linkurl4=\"$linkurl4\"; ");
fputs($cnf,"\$linktitle5=\"$linktitle5\"; \$linkurl5=\"$linkurl5\"; ");
fputs($cnf,"\$linktitle6=\"$linktitle6\"; \$linkurl6=\"$linkurl6\"; ");
fputs($cnf,"\$linktitle7=\"$linktitle7\"; \$linkurl7=\"$linkurl7\"; ");
fputs($cnf,"\$linktitle8=\"$linktitle8\"; \$linkurl8=\"$linkurl8\"; ");
fputs($cnf,"\$friendname1=\"$friendname1\"; ");
fputs($cnf,"\$friendname2=\"$friendname2\"; ");
fputs($cnf,"\$friendname3=\"$friendname3\"; ");
fputs($cnf,"\$friendname4=\"$friendname4\"; ");
fputs($cnf,"\$friendname5=\"$friendname5\"; ");
fputs($cnf,"\$email=\"$email\"; ");
fputs($cnf," ?>");
fclose($cnf);
echo "<center><font face='Arial'>Configuration updated for $sn.</center>";
if ($clearlist != "") {
unlink("$dir/last.txt");
echo "<center><font face='Arial'><p>Last view list cleared.</center>";
}
?>
<head>
<style type='text/css'>
<!--
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: underline}
A:hover {text-decoration: underline}
-->
</style>
<style type='text/css'>
A:link {color: #000000;}
A:visited {color: #000000;}
A:hover {color: #000000;}
</style>
<title>Bouley86.com Profiles: Login</title>
</head>
<body>
<center>
<font face='Arial'>To add a link to your profile,<br>
paste the following code into your profile.<br><br>
<textarea cols=50 rows=6><HTML>Check out my <A HREF="<? echo $serviceurl; ?>/view.php?sn=<? echo $sn; ?>&rn=%n&a=b" TARGET="_self">Bouley86.com Profile</A>.</textarea>
<form action="profile.php?mode=login" method="post">
<input type="hidden" name="sn" value="<? echo $sn; ?>">
<input type="hidden" name="pass" value="<? echo $pass; ?>">
<input type="submit" value="Back To Config">
</form></center>
<?
} else {
echo "<head><style type='text/css'>
<!--
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: underline}
A:hover {text-decoration: underline}
-->
</style>
<style type='text/css'>
A:link {color: #000000;}
A:visited {color: #000000;}
A:hover {color: #000000;}
</style><title>Bouley86.com Profiles: Login</title></head><body><p><center><font face='Arial'>Incorrect usage.</p>";
}
} else {
echo "<head><style type='text/css'>
<!--
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: underline}
A:hover {text-decoration: underline}
-->
</style>
<style type='text/css'>
A:link {color: #000000;}
A:visited {color: #000000;}
A:hover {color: #000000;}
</style><title>Bouley86.com Profiles: Login</title></head><body><p><center><font face='Arial'><b>Logging In.</b></p>";
?>
<center>
<form action="profile.php?mode=login" method="post">
<table>
<tr>
<td><font face='Arial'>Name: </td>
<td><input type=text name=sn></td>
</tr>
<tr>
<td><font face='Arial'>Password: </td>
<td><input type=password name=pass></td>
</tr>
</table>
<p><input type="submit" value="Login"></p>
</form>
<p><font face='Arial'>If you don't have an account, <a href="new.php">signup</a> for one.</p>
<p>
<?
}
?>
scoutt
02-24-2003, 03:44 PM
if ($mode == "confirm") {
should be
if ($_GET["mode"] == "confirm") {
and I hav easked this before,
where ar ethese coming from
$spcontent1 = stripslashes(htmlspecialchars($spcontent1));
$spcontent2 = stripslashes(htmlspecialchars($spcontent2));
$spcontent3 = stripslashes(htmlspecialchars($spcontent3));
$spcontent4 = stripslashes(htmlspecialchars($spcontent4));
$spcontent5 = stripslashes(htmlspecialchars($spcontent5));
also why do you have all that sutff in ther for css, you only need it once.
Bouley86
02-24-2003, 04:15 PM
that stuff has to do with the content of sub pages and all this other stuff. i dont know why it's that way this is the way the script was when i got it but i am workin on a better way to handle it.
scoutt
02-24-2003, 04:19 PM
but where is it coming from?
where does this variable coe from? $spcontent1
and you wouldn't need it anymore if you goto the db would ya?
Bouley86
02-24-2003, 04:22 PM
and changing the thing with the mode didnt make a difference..it still just shows a blank page..
Bouley86
02-24-2003, 04:24 PM
it comes from the mods.php file..the one tha's used to edit the pages and stuff like that.
Bouley86
02-24-2003, 04:26 PM
and no i probably wouldn't need it anymore..but im still working on learning all this stuff..so i don't know if i'd keep it or not.
scoutt
02-24-2003, 04:34 PM
once you figure out that mysql is better and faster you won't go back to flat files anymore :P
Bouley86
02-24-2003, 04:39 PM
Do you see anything else in my profile.php file that would be messing stuff up because it still isnt showing anything when I go to it.
scoutt
02-24-2003, 04:51 PM
here try this, same page just cleaned up
<?
include("settings.php");
?>
<html><head><style type='text/css'>
<!--
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: underline}
A:hover {text-decoration: underline}
-->
</style>
<style type='text/css'>
A:link {color: #000000;}
A:visited {color: #000000;}
A:hover {color: #000000;}
</style>
<?
if ($_GET["mode"] == "confirm") {
$db = mysql_connect("localhost", "bouley86", "****");
mysql_select_db("profiledb",$db);
$select = mysql_query("select * from users where id = '{$_GET["id"]}'");
if(mysql_num_rows($select)){
$row = mysql_fetch_array($select);
$now = time();
if ($now - $row["time_stamp"] < 432000){
?>
<title>Bouley86.com Profiles: Confirmation</title></head>
<body><center><font face='Arial'><p>Your Confirmation is now complete.
You can use the form below to log in.</p><center>
<form action="profile.php?mode=login" method="post">
<table>
<tr>
<td><font face='Arial'>Name: </td>
<td><input type=text name=sn></td>
</tr>
<tr>
<td><font face='Arial'>Password: </td>
<td><input type=password name=pass></td>
</tr>
</table>
<p><input type="submit" value="Login"></p>
</form></center>
<?
} else {
echo"<title>Bouley86.com Profiles: Confirmation</title></head>
<body><center><font face='Arial'>Either you've reached this page by error or you waited longer than 5 days before you registered. Please sign up again.</center>";
}
}
} elseif ($_GET["mode"] == "login") {
if ((isset($sn)) && (isset($pass))) {
if (($sn != "") && ($pass != "")) {
$dir = "$userpath/$sn";
include("$dir/pass.php");
if ($pass == $mypass) {
// SHOW THE SCREEN
include("mods.php");
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Incorrect login.</p></center>";
}
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Incorrect login.</p></center>";
}
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Username and/or password not entered.</p></center>";
}
} elseif ($_GET["mode"] = "update") {
echo "<font face='Arial'><center><b><p>Update mode.</p></b>";
$dir = "$userpath/$sn";
$cnf = fopen("$dir/config.php","w+");
$maintext = stripslashes(htmlspecialchars($maintext));
$spcontent1 = stripslashes(htmlspecialchars($spcontent1));
$spcontent2 = stripslashes(htmlspecialchars($spcontent2));
$spcontent3 = stripslashes(htmlspecialchars($spcontent3));
$spcontent4 = stripslashes(htmlspecialchars($spcontent4));
$spcontent5 = stripslashes(htmlspecialchars($spcontent5));
$sptitle1 = stripslashes(htmlspecialchars($sptitle1));
$sptitle2 = stripslashes(htmlspecialchars($sptitle2));
$sptitle3 = stripslashes(htmlspecialchars($sptitle3));
$sptitle4 = stripslashes(htmlspecialchars($sptitle4));
$sptitle5 = stripslashes(htmlspecialchars($sptitle5));
fputs($cnf,"<? ");
fputs($cnf,"\$sn=\"$sn\"; ");
fputs($cnf,"\$ip=\"$REMOTE_ADDR\"; ");
fputs($cnf,"\$font=\"$font\"; \$colortext=\"$colortext\"; ");
fputs($cnf,"\$colorback=\"$colorback\"; \$colorlink=\"$colorlink\"; ");
fputs($cnf,"\$coloralink=\"$coloralink\"; \$colorvlink=\"$colorvlink\"; ");
fputs($cnf,"\$maintext=\"$maintext\"; ");
fputs($cnf,"\$sptitle1=\"$sptitle1\"; \$spcontent1=\"$spcontent1\"; ");
fputs($cnf,"\$sptitle2=\"$sptitle2\"; \$spcontent2=\"$spcontent2\"; ");
fputs($cnf,"\$sptitle3=\"$sptitle3\"; \$spcontent3=\"$spcontent3\"; ");
fputs($cnf,"\$sptitle4=\"$sptitle4\"; \$spcontent4=\"$spcontent4\"; ");
fputs($cnf,"\$sptitle5=\"$sptitle5\"; \$spcontent5=\"$spcontent5\"; ");
fputs($cnf,"\$linktitle1=\"$linktitle1\"; \$linkurl1=\"$linkurl1\"; ");
fputs($cnf,"\$linktitle2=\"$linktitle2\"; \$linkurl2=\"$linkurl2\"; ");
fputs($cnf,"\$linktitle3=\"$linktitle3\"; \$linkurl3=\"$linkurl3\"; ");
fputs($cnf,"\$linktitle4=\"$linktitle4\"; \$linkurl4=\"$linkurl4\"; ");
fputs($cnf,"\$linktitle5=\"$linktitle5\"; \$linkurl5=\"$linkurl5\"; ");
fputs($cnf,"\$linktitle6=\"$linktitle6\"; \$linkurl6=\"$linkurl6\"; ");
fputs($cnf,"\$linktitle7=\"$linktitle7\"; \$linkurl7=\"$linkurl7\"; ");
fputs($cnf,"\$linktitle8=\"$linktitle8\"; \$linkurl8=\"$linkurl8\"; ");
fputs($cnf,"\$friendname1=\"$friendname1\"; ");
fputs($cnf,"\$friendname2=\"$friendname2\"; ");
fputs($cnf,"\$friendname3=\"$friendname3\"; ");
fputs($cnf,"\$friendname4=\"$friendname4\"; ");
fputs($cnf,"\$friendname5=\"$friendname5\"; ");
fputs($cnf,"\$email=\"$email\"; ");
fputs($cnf," ?>");
fclose($cnf);
echo "<center><font face='Arial'>Configuration updated for $sn.</center>";
if ($clearlist != "") {
unlink("$dir/last.txt");
echo "<center><font face='Arial'><p>Last view list cleared.</center>";
}
?>
<title>Bouley86.com Profiles: Login</title>
</head>
<body>
<center>
<font face='Arial'>To add a link to your profile,<br>
paste the following code into your profile.<br><br>
<textarea cols=50 rows=6><HTML>Check out my <A HREF="<? echo $serviceurl; ?>/view.php?sn=<? echo $sn; ?>&rn=%n&a=b" TARGET="_self">Bouley86.com Profile</A>.</textarea>
<form action="profile.php?mode=login" method="post">
<input type="hidden" name="sn" value="<? echo $sn; ?>">
<input type="hidden" name="pass" value="<? echo $pass; ?>">
<input type="submit" value="Back To Config">
</form></center>
<?
else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><p><center><font face='Arial'>Incorrect usage.</p>";
}
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><p><center><font face='Arial'><b>Logging In.</b></p>";
?>
<center>
<form action="profile.php?mode=login" method="post">
<table>
<tr>
<td><font face='Arial'>Name: </td>
<td><input type=text name=sn></td>
</tr>
<tr>
<td><font face='Arial'>Password: </td>
<td><input type=password name=pass></td>
</tr>
</table>
<p><input type="submit" value="Login"></p>
</form>
<p><font face='Arial'>If you don't have an account, <a href="new.php">signup</a> for one.</p>
<p>
<?
}
?>
Bouley86
02-24-2003, 04:55 PM
i tried that and im still getting a blank page...
scoutt
02-24-2003, 04:57 PM
did you hard refresh? ctrl & f5
and you don't see nothing? noteven an error message?
what is the url you are using?
Bouley86
02-24-2003, 05:07 PM
http://profiles.bouley86.com/profile.php
scoutt
02-24-2003, 05:24 PM
try this
<?
include("settings.php");
?>
<html><head><style type='text/css'>
<!--
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: underline}
A:hover {text-decoration: underline}
-->
</style>
<style type='text/css'>
A:link {color: #000000;}
A:visited {color: #000000;}
A:hover {color: #000000;}
</style>
<?
if ($_GET["mode"] == "confirm") {
$db = mysql_connect("localhost", "bouley86", "****");
mysql_select_db("profiledb",$db);
$select = mysql_query("select * from users where id = '{$_GET["id"]}'");
if(mysql_num_rows($select)){
$row = mysql_fetch_array($select);
$now = time();
if ($now - $row["time_stamp"] < 432000){
?>
<title>Bouley86.com Profiles: Confirmation</title></head>
<body><center><font face='Arial'><p>Your Confirmation is now complete.
You can use the form below to log in.</p><center>
<form action="profile.php?mode=login" method="post">
<table>
<tr>
<td><font face='Arial'>Name: </td>
<td><input type=text name=sn></td>
</tr>
<tr>
<td><font face='Arial'>Password: </td>
<td><input type=password name=pass></td>
</tr>
</table>
<p><input type="submit" value="Login"></p>
</form></center>
<?
} else {
echo"<title>Bouley86.com Profiles: Confirmation</title></head>
<body><center><font face='Arial'>Either you've reached this page by error or you waited longer than 5 days before you registered. Please sign up again.</center>";
}
}
} elseif ($_GET["mode"] == "login") {
if ((isset($sn)) && (isset($pass))) {
if (($sn != "") && ($pass != "")) {
$dir = "$userpath/$sn";
include("$dir/pass.php");
if ($pass == $mypass) {
// SHOW THE SCREEN
include("mods.php");
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Incorrect login.</p></center>";
}
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Incorrect login.</p></center>";
}
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Username and/or password not entered.</p></center>";
}
} elseif ($_GET["mode"] = "update") {
echo "<font face='Arial'><center><b><p>Update mode.</p></b>";
$dir = "$userpath/$sn";
$cnf = fopen("$dir/config.php","w+");
$maintext = stripslashes(htmlspecialchars($maintext));
$spcontent1 = stripslashes(htmlspecialchars($spcontent1));
$spcontent2 = stripslashes(htmlspecialchars($spcontent2));
$spcontent3 = stripslashes(htmlspecialchars($spcontent3));
$spcontent4 = stripslashes(htmlspecialchars($spcontent4));
$spcontent5 = stripslashes(htmlspecialchars($spcontent5));
$sptitle1 = stripslashes(htmlspecialchars($sptitle1));
$sptitle2 = stripslashes(htmlspecialchars($sptitle2));
$sptitle3 = stripslashes(htmlspecialchars($sptitle3));
$sptitle4 = stripslashes(htmlspecialchars($sptitle4));
$sptitle5 = stripslashes(htmlspecialchars($sptitle5));
fputs($cnf,"<? ");
fputs($cnf,"\$sn=\"$sn\"; ");
fputs($cnf,"\$ip=\"$REMOTE_ADDR\"; ");
fputs($cnf,"\$font=\"$font\"; \$colortext=\"$colortext\"; ");
fputs($cnf,"\$colorback=\"$colorback\"; \$colorlink=\"$colorlink\"; ");
fputs($cnf,"\$coloralink=\"$coloralink\"; \$colorvlink=\"$colorvlink\"; ");
fputs($cnf,"\$maintext=\"$maintext\"; ");
fputs($cnf,"\$sptitle1=\"$sptitle1\"; \$spcontent1=\"$spcontent1\"; ");
fputs($cnf,"\$sptitle2=\"$sptitle2\"; \$spcontent2=\"$spcontent2\"; ");
fputs($cnf,"\$sptitle3=\"$sptitle3\"; \$spcontent3=\"$spcontent3\"; ");
fputs($cnf,"\$sptitle4=\"$sptitle4\"; \$spcontent4=\"$spcontent4\"; ");
fputs($cnf,"\$sptitle5=\"$sptitle5\"; \$spcontent5=\"$spcontent5\"; ");
fputs($cnf,"\$linktitle1=\"$linktitle1\"; \$linkurl1=\"$linkurl1\"; ");
fputs($cnf,"\$linktitle2=\"$linktitle2\"; \$linkurl2=\"$linkurl2\"; ");
fputs($cnf,"\$linktitle3=\"$linktitle3\"; \$linkurl3=\"$linkurl3\"; ");
fputs($cnf,"\$linktitle4=\"$linktitle4\"; \$linkurl4=\"$linkurl4\"; ");
fputs($cnf,"\$linktitle5=\"$linktitle5\"; \$linkurl5=\"$linkurl5\"; ");
fputs($cnf,"\$linktitle6=\"$linktitle6\"; \$linkurl6=\"$linkurl6\"; ");
fputs($cnf,"\$linktitle7=\"$linktitle7\"; \$linkurl7=\"$linkurl7\"; ");
fputs($cnf,"\$linktitle8=\"$linktitle8\"; \$linkurl8=\"$linkurl8\"; ");
fputs($cnf,"\$friendname1=\"$friendname1\"; ");
fputs($cnf,"\$friendname2=\"$friendname2\"; ");
fputs($cnf,"\$friendname3=\"$friendname3\"; ");
fputs($cnf,"\$friendname4=\"$friendname4\"; ");
fputs($cnf,"\$friendname5=\"$friendname5\"; ");
fputs($cnf,"\$email=\"$email\"; ");
fputs($cnf," ?>");
fclose($cnf);
echo "<center><font face='Arial'>Configuration updated for $sn.</center>";
if ($clearlist != "") {
unlink("$dir/last.txt");
echo "<center><font face='Arial'><p>Last view list cleared.</center>";
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><p><center><font face='Arial'>Incorrect usage.</p>";
}
?>
<center>
<font face='Arial'>To add a link to your profile,<br>
paste the following code into your profile.<br><br>
<textarea cols=50 rows=6><HTML>Check out my <A HREF="<? echo $serviceurl; ?>/view.php?sn=<? echo $sn; ?>&rn=%n&a=b" TARGET="_self">Bouley86.com Profile</A>.</textarea>
<form action="profile.php?mode=login" method="post">
<input type="hidden" name="sn" value="<? echo $sn; ?>">
<input type="hidden" name="pass" value="<? echo $pass; ?>">
<input type="submit" value="Back To Config">
</form></center>
<?
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><p><center><font face='Arial'><b>Logging In.</b></p>";
?>
<title>Bouley86.com Profiles: Login</title>
</head>
<body>
<center>
<form action="profile.php?mode=login" method="post">
<table>
<tr>
<td><font face='Arial'>Name: </td>
<td><input type=text name=sn></td>
</tr>
<tr>
<td><font face='Arial'>Password: </td>
<td><input type=password name=pass></td>
</tr>
</table>
<p><input type="submit" value="Login"></p>
</form>
<p><font face='Arial'>If you don't have an account, <a href="new.php">signup</a> for one.</p>
<p>
<?
}
?>
Bouley86
02-24-2003, 07:52 PM
Alrite, it shows up now..but it doesn't go to the screen I want it to. When i go to profile.php i want it to automatically go the login that is at the bottom of all the code. I'm trying to figure out how to do it myself..
scoutt
02-24-2003, 08:09 PM
you might not find it, if you do good job
but look at this line and tell me wha tis wrong
} elseif ($_GET["mode"] = "update") {
Bouley86
02-24-2003, 08:31 PM
it needs a second = rite? yup cuz i just tried it. Alrite now i'm having problems handling the logining in. here's what i have
} elseif ($_GET["mode"] == "login") {
if ((isset($sn)) && (isset($pass))) {
if (($sn != "") && ($pass != "")) {
$db = mysql_connect("localhost", "bouley86", "****");
mysql_select_db("profiledb",$db);
$select = mysql_query("select * from users where sn = '{$_GET["sn"]}'");
if(mysql_num_rows($select)){
$row = mysql_fetch_array($select);
if ($pass == $row["pass"]) {
include("mods.php");
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Incorrect login.</p></center>";
}
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Incorrect login.</p></center>";
}
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Incorrect login.</p></center>";
}
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Username and/or password not entered.</p></center>";
}
And i thought that should be rite but i can't get it to go thru to the profile.php?mode=update page..
And what i want it to do is to check for all the times a certain screen name (we'll say 'test') occours (that way people can use the same membername or whatever) and then i want it to check the password it finds and if it matches i want it to get the id and use that for the script to identify the person. I don't know if i really explained that well or not..
scoutt
02-24-2003, 09:17 PM
Originally posted by Bouley86
it needs a second = rite? yup cuz i just tried it. Alrite now i'm having problems handling the logining in. here's what i have
} elseif ($_GET["mode"] == "login") {
if ((isset($sn)) && (isset($pass))) {
if (($sn != "") && ($pass != "")) {
$db = mysql_connect("localhost", "bouley86", "****");
mysql_select_db("profiledb",$db);
$select = mysql_query("select * from users where sn = '{$_GET["sn"]}'");
if(mysql_num_rows($select)){
$row = mysql_fetch_array($select);
if ($pass == $row["pass"]) {
include("mods.php");
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Incorrect login.</p></center>";
}
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Incorrect login.</p></center>";
}
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Incorrect login.</p></center>";
}
} else {
echo "<title>Bouley86.com Profiles: Login</title></head><body><center><font face='Arial'><p>Username and/or password not entered.</p></center>";
}
And i thought that should be rite but i can't get it to go thru to the profile.php?mode=update page..
well it looks ok, but take
if ((isset($sn)) && (isset($pass))) {
if (($sn != "") && ($pass != "")) {
and change it or get rid of it. they both say the samething, if they are set then they can't be empty.
if ($_POST["sn"] != "" && $_POST["pass"] != "") {
and since you are posting the info you can't use $_GET[]
so change the GET into a POST in the query. also change this
if ($pass == $row["pass"]) {
TO
if ($_POST["pass"] == $row["pass"]) {
that should work.
And what i want it to do is to check for all the times a certain screen name (we'll say 'test') occours (that way people can use the same membername or whatever) and then i want it to check the password it finds and if it matches i want it to get the id and use that for the script to identify the person. I don't know if i really explained that well or not..
why? it is not practical to check how many times it has been used. you need a unique screen name because what if 3 users have the same name and password, how will it know which one to take? and trust me, a lot of people use a password like "qwerty" I have seen it a lot.
so then if you want to keep a track on them then you have to use sessions or cookies.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.