Jump to content

Help with PHP Redirect Code


jamesclues
Go to solution Solved by jamesclues,

Recommended Posts

Basically I have form that after submission i want it to goto http://report.domain.com/  domain.com user entered in the form

 

this is where the domain is picked up from    $website =($_POST['website']);

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"1;URL=http://report.domain.com/<$website>">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"1;URL=freereport.html\">";
}
?>






</body>
</html>

please, can anyone help I have been searching on google for 3 hours unable to find a solution.

Link to comment
Share on other sites

I Basically when a user submits the form $website="domain.com"  so i want the user redirected to http://reports.mydomain.com/domain.com    

 

The red is the domain.com from the form submitted

 

 

print "<meta http-equiv=\"refresh\" content=\"1;URL=http://report.domain.com/<$website>">";

 

Where read at the top $website  is where the form submitted domain will appear...

 

I tried this code but i get error 500 server

// send email$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"1;URL=http://report.domain.com/<?php echo $website ?>">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"1;URL=freereport.html\">";
}
?>
Edited by jamesclues
Link to comment
Share on other sites

That still tells us exactly nothing about what – is – wrong. Why is it so hard to understand that we aren't sitting in front of your screen?

 

Anyway, forget about it. This code should be rewritten from top to bottom, because the 90s are over.

  • Replace the shady mail() stuff with a proper mail library like PHPMailer.
  • Get rid of the stupid refresh. It's annoying and violates the accessibility guidelines. Do a redirect with the Location header.
  • Stop injecting unfiltered values into the URL. Validate the input and make sure it is in fact a domain.

Chances are this was just the tip of the iceberg, so don't expect it to be a quick fix.

  • Like 1
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.