#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    PHP session problem


    Im trying to make when you put your name, than redirect to page when will echo the your name (something like login, but this is just practice). When i try code, browser not redirect me to another page.


    Code:
    <?php session_start();    if(isset($_POST['user'])){ 	$user = $_POST['user']; 		$_SESSION = $_POST['user']; }   else { 	echo "Wrote name"; } if(!$_SESSION == NULL){ header('Location: http://127.0.0.1/view.php'); } ?>  <form action="" method "POST">  <input type = "text" name="user"> <input type = "submit" value="Submit">   </form>
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Location
    Seattle, U.S.A.
    Posts
    712
    Rep Power
    12
    Please use the php tags and format you code so it's not all on line .
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    This won't work:
    PHP Code:
    if(!$_SESSION == NULL
    I'm assuming you're trying to do something like this instead:
    PHP Code:
    if(!empty($_SESSION['user'])){ 
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0
    @msteudel sry, @E-Oreo

    that is right but, still no redirect

IMN logo majestic logo threadwatch logo seochat tools logo