Jump to content

Submitting a form and Redirecting


gazfocus

Recommended Posts

I have got a contact form on my site that I'm making but I want the query in the form to be sent via email to myself but also for the page to then redirect to a page notifying the user that the information has been sent.

 

Is there a way to do this? Thanks

Link to comment
Share on other sites

i use javascript like this :

 

if login conditions are ok then : 

<script language="javascript">
parent.location.replace  ('index.php'); /* or document.location.replace ('index.php')
document.refresh();
</script>

Thanks, but what I'm looking for is some way of redirecting only when the contents of the form have been emailed using

<form action="mailto:[b]email address[/b]" method="post" name="query">

Link to comment
Share on other sites

<?php 

// If form was submitted
if ( isset($_POST['submit'])) {

   ... validate form and send email to you.



}
// Form not submited
else {
?>
<form action="<?php echo"$_SERVER['PHP_SELF']"; ?>"  method="post">

... form crap
<input type="submit" name="submit" value="Submit" />

</form> 
<?php
}
?>

 

 

Link to comment
Share on other sites

then you can use the javascript code as a javascript function and control it in onSubmit() event of <form> tag.

 

<form onSubmit="redirect()"....>

 

i don't know that is an exact solve. just a way...

 

 

 

You don't need to use javascript. Find a tutorial online to see how php would redirect. But in the example I gave, it is not needed since it would show up different results depending on if the form was or wasn't submitted.

Link to comment
Share on other sites

Thanks, but what I'm looking for is some way of redirecting only when the contents of the form have been emailed using

<form action="mailto:[b]email address[/b]" method="post" name="query">

 

That is a horrible way to mail..

 

I suggest use the php mail() function.

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.