brigadechief Posted March 12, 2008 Share Posted March 12, 2008 Hey I have made a simple form for contact. I provide you guys with the script so you may help me <?php $username="*********"; $password="*********"; $database="*********"; $fnavn=$_POST['fnavn']; $enavn=$_POST['enavn']; $telefon=$_POST['telefon']; $email=$_POST['email']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO kontakter VALUES ('','$fnavn','$enavn','$telefon','$email')"; mysql_query($query); mysql_close(); echo "Takk for at du ønsker mer informasjon. Vi vil ta så fort som mulig."; ?> this is the script I called insert.php and the actual form is: <form action="insert.php" method="post"> <table width="600" border="0"> <tr> <th class="formHeader" scope="row">Fornavn:</th> <td><input type="text" name="fnavn"></td> </tr> <tr> <th class="formHeader" scope="row">Etternavn:</th> <td><input type="text" name="enavn"></td> </tr> <tr> <th class="formHeader" scope="row">Telefon:</th> <td><input type="text" name="telefon"></td> </tr> <tr> <th class="formHeader" scope="row">E-mail:</th> <td><input type="text" name="email"></td> </tr> <tr> <th class="formHeader" scope="row"> </th> <td><input type="Submit"></td> </tr> </table> </form> I want this!! When a user enter the details and hit the "submit-button" he will just get a message that says "Thanks for letting us know, we will take contact as soon as possible" in the same window and then the page refresh's automatically and the user can keep reading or whatever he's/she's doing. If somebody got any ideas how this can be done or other ideas I would like to hear from you. Thanks, Andreas Quote Link to comment Share on other sites More sharing options...
p2grace Posted March 12, 2008 Share Posted March 12, 2008 Change your echo statement to this: <?php echo "Takk for at du ønsker mer informasjon. Vi vil ta så fort som mulig. <script type="text/javascript"> setTimeout("window.location='wherever.php';",5000); // wil redirect to wherever.php in 5 seconds </script> "; ?> Let me know if that works Quote Link to comment Share on other sites More sharing options...
craygo Posted March 12, 2008 Share Posted March 12, 2008 What you want to do is check to make sure the insert query has run and then echo out the message change the code to this <?php $username="*********"; $password="*********"; $database="*********"; $fnavn=$_POST['fnavn']; $enavn=$_POST['enavn']; $telefon=$_POST['telefon']; $email=$_POST['email']; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query = "INSERT INTO kontakter VALUES ('','$fnavn','$enavn','$telefon','$email')"; $result = @mysql_query($query); if($result){ // change the link(xxxxx.xxx) to the page you would like to return them to <META HTTP-EQUIV="Refresh" content="4;url=xxxxxx.xxx"> echo "Takk for at du ønsker mer informasjon. Vi vil ta så fort som mulig."; } else { // Put a message saying the query did not work die("Could not send message".mysql_error()); } mysql_close(); ?> Ray Quote Link to comment Share on other sites More sharing options...
brigadechief Posted March 12, 2008 Author Share Posted March 12, 2008 Thanks people for quick answers, really appriciated I will try it now Thanks, Andreas Quote Link to comment Share on other sites More sharing options...
brigadechief Posted March 12, 2008 Author Share Posted March 12, 2008 It works! Thanks a lot Have a nice day Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.