/    Sign up×
Community /Pin to ProfileBookmark

Need redirect to contact page after submit

[B]Hello all, need some help. Need to redirect page after submit. Here is my contact.html form:[/B]

[CODE]<form name=”contactform” action=”contactform.php” method=”post”>
<table border=”0″ cellpadding=”3″>
<tr>
<td><font size=”6″><a href=”http://www.something.com/” style=”text-decoration:none”>HOME</a></font></td>
<td rowspan=”7″ width=”1020″><center><font size=”3″>IF YOU HAVE A QUESTION, COMMENT, OR INQUIRY REGARDING RATES PLEASE CONTACT US AT:<br />INFO&#64;SOMETHING.COM<br /><br />YOU MAY ALSO CONTACT US THROUGH OUR FORM:<br /><br />
NAME:<input type=”text” size=”36″ name=”name” class=”text1″ style=”font-family: times” />
<br />
EMAIL:<input type=”text” size=”36″ name=”email” class=”text2″ style=”font-family: times” />
<br />
<br />
<textarea name=”text” rows=”5″ cols=”139″ style=”font-family: times”>
</textarea>
<br />
<br />
<a onclick=”document.contactform.reset();return false;” href=”#”><img alt=”Reset” src=”reset.gif” border=”0″ /></a>&nbsp;/
<input type=”image” src=”submit.gif” alt=”Submit” />
</font></center></td>
</tr>[/CODE]

[B]Here is my contactform.php file:[/B]

[CODE]<?php
$name = $_POST[‘name’];
$email = $_POST[’email’];
$text = $_POST[‘text’];

mysql_connect (“xxxxx”, “xxxxx”, “xxxxx”) or die (‘Error: ‘ . mysql_error());
mysql_select_db (“xxxxx”);

$query=”INSERT INTO contacttable (name, email, text)VALUES (‘$name’,’$email’,’$text’)”;

mysql_query($query) or die (‘error updating database’ . mysql_error());

?>[/CODE]

[B]Once i sumbit, the window goes blank, to [url]www.something.com/contactform.php[/url] with “done” at bottom of page. The input is sent to my databse perfectly, but I would like when the form is submitted to clear all fields and stay on the contact page if possible (prefered), or if that can’t happen for it to redirect to the contact page after submit with fields all clear.

I know nothing of php, just been inputing what everyone suggest. which has been a great help. This is the last problem i need fix and my contact page would be ready. anyone know what to insert? thanks! [/B]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@stephan_gerlachOct 01.2008 — simply add this to your contactform.php

[code=php]
header('location: contact.html');
exit;
[/code]


You need to make sure that there is no output in the contactform.php. Not even a whitespace.
Copy linkTweet thisAlerts:
@ADLEauthorOct 02.2008 — Thanks dude, that worked perfectly!
Copy linkTweet thisAlerts:
@xvszeroOct 02.2008 — What exactly does the "exit" part do? I have just been using a header alone and it seems to work.
×

Success!

Help @ADLE spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...