Jump to content

[SOLVED] ampersands


fou2enve

Recommended Posts

I have a login page that posts to itself along with a url attached (ie login.php?url=protectedpage.php?ID=9230&B=4949 ). the problem I'm having is getting anything after the & to stick. Here's what i mean:

 

 

if (isset($_POST['name']) || isset($_POST['pass'])) {
    // form submitted
    // check for required values
    if (empty($_POST['name'])) {
        die ("ERROR: Please enter username!");
    }
    if (empty($_POST['pass'])) {
        die ("ERROR: Please enter password!");
    }

    if ($password="password") {
        // if a row was returned
        // authentication was successful
        // create session and set cookie with username
        session_start();
        $_SESSION['auth'] = 1;
        setcookie("username", $_POST['name'], time()+(60*5));
        echo "Access granted!";
	$url = (isset($_GET['url'])) ? "$_GET['url']" :'index.php';
    echo "<meta http-equiv=".'"'.'refresh'.'"'.' content="'."12;url=$url".'">';
echo $url;
    }
    else {
        // no result
        // authentication failed
        echo "ERROR: Incorrect username or password!";
    }
    

}
else {
    // no submission
    // display login form
?>
    <html>
    <head></head>
    <body>
    <center>
    <form method="post" action="login.php?url=<? echo $url; ?>">
    Username <input type="text" name="name" value="AuthorizedUser">
    <p />
    Password <input type="password" name="pass">
    <p />
    <input type="submit" name="submit" value="Log In">
    </center>
    </body>
    </html>
<?php
}

?> 

 

im using $url=$_GET['url']; to get the URL and then later on in the script echoing $url into a meta refresh after a successful auth (actual auth process uses mysql but i pulled that out for now) but when the outputs i get: protectedpage.php?ID=9230 nothing else. I've tried using %26 in the initial url but that didnt help. I tried suing str_replace to try and replace & with %26 right before it outputted, but that didn't work. :-\

 

 

ideas?

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.