View Full Version : making blog interface with registration and junk
boxxertrumps
12-16-2006, 10:55 PM
Im creating a module akin to blogger.com and i have run into a snag...
im using this to create a user...
$new_UN = $_POST["post_user_new"]
$new_PW = $_POST["post_pass_new"]
$new_EM = $_POST["post_mail_new"]
INSERT INTO `login` ( `user` , `password` , `email` )
VALUES ( '$new_UN', '$new_PW', '$new_EM' );
CREATE TABLE `$new_UN` (`date` INT UNSIGNED NOT NULL , `title` VARCHAR( 64 ) NOT NULL ,
`entry` TEXT NOT NULL , `autoID` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY );
How would I have a user input his/her user name and password then have the details inserted into the table that was created along with his account?
thetestingsite
12-16-2006, 11:48 PM
I'm not quite sure what you are asking, so let me know if this is right. You want to insert the user info in a table that's already in the db, then (after that), you want to create a new table with the name of the new user that just registered? Is this what you are trying to accomplish?
boxxertrumps
12-17-2006, 01:23 AM
no, i mean after that is done and the user adds an entry into his blog.
how would i have the password from the login form and the password in the database compared to each other.
then if they are the same, the entry is added, and if they are different, it displays a page that says "Incorrect password" or something.
thetestingsite
12-17-2006, 03:07 AM
you could connect to the database, then user the query
$userInfo = mysql_query("SELECT * FROM `users` where `username`='$username'");
then from there, use
//see if username is in the database
if (!mysql_num_rows($userInfo)) {
//display error message.
echo 'No such user!';
}
else { //if it is in the db, continue
$q = mysql_fetch_array($userInfo);
if ($password != $q[password]) {
//if entered password not equal to pwd in db display error
echo 'wrong password';
}
else { //if pwd is correct, display msg
echo 'You are logged in!';
postblog(); //use postblog function (or any other function)
}
}
Hope this helps!
boxxertrumps
12-17-2006, 03:20 AM
Thanks thetestingsite.
heres the new code.
// connection info
if ( $_POST["post_user"] != '') {
$user = $_POST["post_user"];
$password = $_POST["post_pass"];
$title = $_POST["post_title"];
$entry = $_POST["post_entrys"];
$date = date()
$userInfo = mysql_query("SELECT * FROM `login` where `user`='$user'");
if (!mysql_num_rows($userInfo)) {echo 'No such user!';}
else {
$q = mysql_fetch_array($userInfo);
if ($password != $q[password]) { echo 'wrong password'; }
else {echo 'Post Successful';
INSERT INTO `$user` ( `date` , `title` , `entry` ) VALUES ( '$title', '$entry', '$date' );
}
}
}
else {
?>
<form action="<?php echo $_SERVER[PHP_SELF]; ?>" method="post">
Username:<input type="text" name="post_user"><br />
Password:<input type="password" name="post_pass"><br />
Title:<input type="text" name="post_title"><br />
Entry:<textarea rows="20" colums="50" name="post_entry"></textarea><br />
<input type="submit" value="submit"> </form>
<?php }; ?>
but there is an error...
Parse error: parse error, unexpected T_VARIABLE in C:\wamp\www\blog\blogadd.php on line 13
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.