Jump to content

Recommended Posts

I have a comment section on my website. It requires your name, email, and comment. You can opt to login and then you do not have to fill in your name and email. My form looks like this: 

<tr>
   <td><label for="name">Name:</label></td>
   <input type="submit" id="loginbtn" value="Or Login" onclick="window.location='/login_scripts/login.php'" /></td>
</tr>
<tr>
   <td><label for="name">Email:</label></td>
   <td><input type="email" name="email" id='email'/></td>
</tr>

Once you login, the name and email fields disappear and you can just comment. I grab your user name from the database and insert that as your comment name. Anyways, how can I redirect them back to the comment section after they have been logged in? assuming they arrived at the login page from this specific login button...

Edited by ryanmetzler3
Link to comment
https://forums.phpfreaks.com/topic/285455-redirect-back-to-original-page/
Share on other sites

After they login use the header() to redirect:

header ('Location: http://mydomain.com/myprogram.php#mycommentanchortag');

Note: you need to use the header before any other output to the browser.

Edited by davidannis
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.