Jump to content

Help with PHP Redirect Code


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\">";
}
?>
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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.