0

this is my code:

<?php
    if(isset($_POST['sub']))
    {
        $sql=("insert into info_user(u_fname, u_lname, u_pass, u_number, u_email)values('".($_POST['fname'])."','".($_POST['lname'])."','".($_POST['pass'])."','".($_POST['phone'])."','".($_POST['email'])."')");
        mysql_query($sql, $link);
        echo
        "you are registered successfully"
        "<a href="?action=login">'Login'<a/>";
    }
?>

I have problem with this one : echo "'Login'" there is a php page which contain nothing but some includes and the page with codes above is included. now i want to redirect user to login page, but i don't want to mention a new link.

is there a way to do so?

Pooya
  • 89
  • 3
  • 13
  • 1
    **Danger**: You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). You are also **vulnerable to [SQL injection attacks](http://bobby-tables.com/)** that a modern API would make it easier to [defend](http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php) yourself from. – Quentin Sep 29 '13 at 16:09
  • What does your title have to do with the question? – Barmar Sep 29 '13 at 16:10

1 Answers1

3
$host  = $_SERVER['HTTP_HOST'];
$uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'mypage.php?action=login';
header("Location: http://$host$uri/$extra");

(Source: Manual)

Make sure there is no kind of output (neither php nor html) before you send the header.

TheWolf
  • 1,385
  • 7
  • 16