Having a little trouble getting this code to redirect after send has been clicked.

Just goes to a 404 error page, yet the email still sends, I want the user to know the email has been sent. Any help would be appreciated.
thanks.

CODE:


<td colspan="2" bgcolor="#FFFFFF"> <form enctype="multipart/form-data" method="post" action="/cgi-bin/mailer">
<table border="0" align="center" bgcolor="6883b0">
<tr>
<td><b><font color="#FFFFFF" size="-1">Your name:</font></b></td>
<td><input type="text" name="NAME" maxlength="35" size="37" value=""></td>
</tr>
<tr>
<td><b><font color="#FFFFFF" size="-1">Your email:</font></b></td>
<td><input type="text" name="FROM" maxlength="35" size="37" value=""></td>
</tr>
<tr>
<td><b><font color="#FFFFFF" size="-1">Your comments:</font></b></td>
<td><textarea name="COMMENTS" cols="29" rows="4"></textarea></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Send"> &nbsp; <input type="reset" value="Erase"></td>
</tr>
</table>
<input type="hidden" name="TO" value="">
<input type="hidden" name="SUBJECT" value="**HEYBYRNE.CO.UK - EMAIL**">
<input type="hidden" name="GOTOURL" value="">
</form></td>

Dani AI

Generated

— the fact that the mail goes out but the browser lands on a 404 means the mailer completed its job but the redirect step failed. was right to flag the redirect parameter: start by confirming whether the mailer actually sees and uses whatever hidden field you supplied for the confirmation URL, and whether the target confirmation file really exists and is reachable from the server.

Quick checklist to isolate the problem:

  • Open the confirmation URL directly in a browser to confirm it returns HTTP 200 (watch for case differences and the exact filename).
  • Look at the server access/error logs right after a test submit to see which URL produced the 404. That tells you what the mailer tried to load.
  • Use the browser dev tools (Network → Form Data) or a temporary debug action to see exactly what fields the browser posts to the mailer. A tiny PHP debug endpoint is useful:
<?php
header('Content-Type: text/plain');
var_export($_POST);

Point the form at that script to confirm the redirect field and its value arrive intact.

Common real causes and fixes:

  • Hidden inputs must carry plain text values (no HTML anchors, no unescaped quotes). Malformed attributes can break subsequent fields so the mailer never sees the redirect target. Validate the page markup (for example, with the W3C validator) and fix quoting.
  • Confirm the mailer expects the same hidden-field name you are sending; different mailers use different names. Read the mailer docs or inspect the CGI script to be sure.
  • If the mailer can’t be made to redirect reliably, handle mail on the server (or wrap the mailer) and issue a server-side redirect instead:
<?php
// after sending mail on the server
header('Location: https://your-site.example/thank-you.html');
exit;

These steps will show whether the problem is a missing file, a mismatched parameter name, or malformed HTML.

Recommended Answers

All 2 Replies

Does your form mailer tell you to use <input type="hidden" name="GOTOURL" value=""> ? Or did the instructions come from another mailer?

Does your form mailer tell you to use <input type="hidden" name="GOTOURL" value=""> ? Or did the instructions come from another mailer?

The form mailer tells users to use <input type="hidden" name="GOTOURL" value="">

not other instructions were used.

Thought it would work first time but nope. If fields are left blank however the user is told about this, yet it wont redirect after send is activated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.