Results 1 to 5 of 5

Thread: making blog interface with registration and junk

  1. #1
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default making blog interface with registration and junk

    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?
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    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?
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    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.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    you could connect to the database, then user the query

    Code:
    $userInfo = mysql_query("SELECT * FROM `users` where `username`='$username'");
    then from there, use

    Code:
    //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!
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    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
    Last edited by boxxertrumps; 12-17-2006 at 06:51 PM.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •