Jump to content

lame question re URL


artworthy

Recommended Posts

location ;)

$url="myHome.php"
header("Location: $url");

 

EDIT: as a note it is the one of the first example in the php manual for header

<?php
header("Location: http://www.example.com/"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>

Link to comment
Share on other sites

Still no luck. marked up a login script all lines are working except:

 

$url="http://www.ipingus.com/myFactors.php";

header("Location: $url"); 

 

I get on the browser page:

Parse error: syntax error, unexpected T_STRING in /hermes/bosweb/web255/b2558/sl.artworthy/public_html/iPingus/scripts/login.php on line 57 (this line is the header() function)

 

Thanks

(btw, will read every reply notwithstanding dsl outages)

 

 

Link to comment
Share on other sites

thanks, but it seems the issue had to do with the db PW not reseting as I thought it did. My hosting service forced a reset. But login script still not doing the job:

<?php

// logon script

if ($_POST['email'] != "") {

 

include_once ('./scripts/connect_to_mysql.php');

 

$email = $_POST['email'];

$pass = $_POST['pass'];

 

$email = strip_tags($email);

$pass = strip_tags($pass);

$email = mysql_real_escape_string($email);

$pass = mysql_real_escape_string($pass);

$email = eregi_replace("`", "", $email);

$pass = eregi_replace("`", "", $pass);

 

$pass = md5($pass);

 

//make query

$sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$pass' AND email_activated='1'");

$login_check = mysql_num_rows($sql);

 

if($login_check > 0){

 

    while($row = mysql_fetch_array($sql)){

 

        $id = $row["id"]; 

        session_register('id');

        $_SESSION['id'] = $id;

     

    $mem_name = $row["mem_name"]; 

        session_register('mem_name');

        $_SESSION['mem_name'] = $mem_name;

     

    $email = $row["email"]; 

        session_register('email');

        $_SESSION['email'] = $email;

       

 

        mysql_query("UPDATE members SET last_log_date=now() WHERE id='$id'");

       

        $my_msg = "You're logged on";

header("Location: http://www.ipingus.com/myFactors.php");

        print "return_msg=$my_msg&id=$id&mem_name=$mem_name";

    } // close while

 

 

} else {

$my_msg = "no_good";

    print "return_msg=$my_msg";

exit();

}

 

 

}// close if post

?>

Link to comment
Share on other sites

This is randomness and me just being picky, but if I remember correctly (this is directed up a couple posts), the Location HTTP header should have a full URL, not just a path relative to the web root of the current site.  Or did I dream that at some point...  Hrmmm....  Off to google now...

Link to comment
Share on other sites

if I remember correctly (this is directed up a couple posts), the Location HTTP header should have a full URL, not just a path relative to the web root of the current site.

 

 

Your very correct (as always) corbin, most browsers will fix this, and allow you to do it, thats why people (myself included) are lazy and use that shortcut,

 

<?php
    header("Status: 301"); # 301 Moved Permanently / 302 Temporary moved
    header("Location: http://{$_SERVER['SERVER_NAME']}/home.php");
    exit;
?>

As a side note google likes 301 status when things are moved but doesn't like 302 (or thats what i read somewhere..awaits corbin responces lol)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.