Jump to content

renlfey

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

renlfey's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ok so it does create the cookie but the second part does not work <?php if(isset($_COOKIE['username'])) { echo "Welcome " . $_COOKIE["username"] . "!<br />"; } else include("../include/login-form.php"); ?> BTW THX
  2. OK Awsome, as a noob please bare with me!!!! I have successfully created and displayed the name that i choose but now another issue how do i go about creating the cookie with the username??
  3. True but i dont want the users to automaticly log in the next time they visit the site! , so sessions i think are the way for me to go since the user must login in order to view content its just cookie get saved and session i think your right on this are destroyed wich is what im looking for! But i guess if somone know how to edit my code for cookies also that would be cool too lol
  4. Ok so here is my delema... i would to create a session with user name call 'userlog' so that if the client is logged in it will display a welcome back 'BOB' instead of the login form here is the login(i know its probable wrong but hey im new at this!. <?php session_start(); if(isset($_SESSION['$userlog'])) echo 'Weclome back', '$username'; else include("includes/login-mod.php"); ?> and here is the checklogin script (the one were i need to create a session! <?php $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="rigid gaming"; // Database name $tbl_name="users"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $username=$_POST['username']; $password=$_POST['password']; // To protect MySQL injection (more detail about MySQL injection) $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $username and $password, table row must be 1 row if($count==1){ // Register $username, $password and redirect to file "success.php" session_register("username"); session_register("password"); header("location:../success.php?success==0"); } else { header("location:../success.php?success==1"); } ?> Any help would be greatly apreciated !!!!!!
  5. Ive set it but i think it still needed to be set in the <?php if(isset($_GET['success']) && $_GET['success'] == "1") { echo "Thank you for registering, Your browser will soon be redirected our home page!"; } else { include("../includes/RegistrationForm.php"); } ?> In order for it to be defined stince im its being set from another page! either way weve tested it and its the perfect solution! Thanks again
  6. Success!! Genious i cant beleive i didnt think of that ! The form <form action=register.php method=post> Username:<input name="username" size="30" autocomplete="off" value="" type="text" /><br /><br /> Password:<input name="password" size="30" type="password" /><br /><br /> First Name:<input name="firstname" size="30" type="text" /><br /><br /> Last Name:<input name="lastname" size="30" type="text" /><br /><br /> Email:<input name="email" size="30" type="text" /><br /><br /> Age:<input name="age" size="30" maxlength="2" /><br /><br /> <input type="submit" class="button" value="Register" /> <input type="reset" name="reset" value="Clear" /> </form> -------------------------------------------------------- the register.php <?php include 'mysql-connect.php'; $username = $_POST['username']; $password = $_POST['password']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $age = $_POST['age']; $ip = $_SERVER['REMOTE_ADDR']; $result = mysql_num_rows(mysql_query("SELECT * FROM wwd_users WHERE username='$username'")); if($result == 1) { echo " <script>window.location=\"registration.php?success=0\"</script>"; } else { mysql_query("INSERT INTO wwd_users (username, password, firstname, lastname, age, ip) VALUES ('$username', '$password', '$firstname', '$lastname', '$age', '$ip')"); echo " <script>window.location=\"registration.php?success=1\"</script>"; } ?> -------------------------------------------------------------------- Thanks again seems to work now
  7. o i tried <?php if $_GET["success"] == "1" { echo "Thank you for registering, Your browser will soon be redirected our home page!"; } ----------------------------------------- <?php $_GET["success"] == "1" { echo "Thank you for registering, Your browser will soon be redirected our home page!"; } -------------------------------------------------------------------------<?php if $_GET["success"] == "1"; { echo "Thank you for registering, Your browser will soon be redirected our home page!"; } And im still getting the error any way you can elaborate??? Thx for you quick response!
  8. K guys im new here and in need of a quick fix! im getting Undefined index: success error and here is my code!! <?php if($_get["success"] == "1") { echo "Thank you for registering, Your browser will soon be redirected our home page!"; } else { include("../includes/RegistrationForm.php"); } ?> Any input would be greatly apreciated!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.