Jump to content

Hi everyone!


jmte

Recommended Posts

Hi, my name is maria-teres, and i am desperate for some help. i hope that one of you can help me to resolve my problem.

Lets tell my PHP-story!

 

i have on all my pages

<?PHP

session_start();

if (!$_SESSION['company_loggedin'])

?>

 

 

this because i have one menu, one for guests and one for the registred user.

this works very fine!!

 

BUT.. then i have som forms.

when a user dont fill in a post this messages comes up

 

 

    if (empty($_POST['Name'])) {

echo '<script>alert("Please enter your name");</script>';

    echo '<script>history.back(1);</script>';

exit();

 

} else {

 

the problem is that all the inputs will be deleted, so the user have to write all once again.

when i take away

 

<?PHP

session_start();

if (!$_SESSION['company_loggedin'])

?>

 

the form works fine!. so i dont know what to do? someone?  i hope i have explained well.

thanks!

 

Link to comment
Share on other sites

change

<?PHP
session_start();
if (!$_SESSION['company_loggedin'])
?>

 

to

 

<?PHP
session_start();
if (!$_SESSION['company_loggedin']){
echo "not logged in";
//header("Location: index.php");
}
?>

 

btw- post more code if this doesnt work

Link to comment
Share on other sites

Using the browser history is not the way to handle that problem.  What you should do, is store their $_POST input into a session variable.  In the form you can read that out of the session (if it exists) and repopulate the form using html. 

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.