Page 1 of 1 |
|
Posted: Fri, 17th Aug 2012 01:22 Post subject: Help me customize my contact form confirmation message |
|
 |
So i got the contact form working
Html: Spoiler: | <form action="mail.php" method="POST">
<p>Name</p> <input type="text" name="name">
<p>Email</p> <input type="text" name="email">
<p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br />
<input type="submit" value="SEND">
</form>
|
and mail.php
Spoiler: | <?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "exemple@exemple.com";
$subject = "bla bla blat";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='index.html'> Return Home</a>";
?> |
but my "client" doesnt like the confirmation message that appears on a separate page;
he wants a customized pop-up message on the same page, preferably with the website logo on it. how would i do that please?
ASUS TUF B550M-PLUS | RYZEN 5600x | RTX 3060TI | 16GB DDR4
|
|
Back to top |
|
 |
|
Posted: Fri, 17th Aug 2012 01:40 Post subject: |
|
 |
Add this code to the head of your page.
Code: |
<head>
...
...
...
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('form').submit(function(){
var $form = $(this);
$.ajax({type: 'POST',url: $form.attr('action'),data: $form.serialize(),success: function(response) {$form.append(response);});
return false;
});
});
</script>
</head>
|
You obviously do not add the dots 
|
|
Back to top |
|
 |
|
Posted: Fri, 17th Aug 2012 01:49 Post subject: |
|
 |
I've added it, you can check it here (Ctrl+U) in google chrome
http://gaming-today.com/contact.html
still nothing
ASUS TUF B550M-PLUS | RYZEN 5600x | RTX 3060TI | 16GB DDR4
|
|
Back to top |
|
 |
|
Posted: Fri, 17th Aug 2012 01:58 Post subject: |
|
 |
ok then please use this code:
Code: |
<form action="mail.php" method="POST" onsubmit="return doSubmit(this);">
<p>Name</p> <input type="text" name="name">
<p>Email</p> <input type="text" name="email">
<p>Message</p><textarea name="message" rows="6" cols="25"></textarea><br />
<input type="submit" value="SEND">
</form>
|
Code: |
<script type="text/javascript">
function doSubmit(form){
var $form = $(form);
$.ajax({type: 'POST',url: $form.attr('action'),data: $form.serialize(),success: function(response) {$form.append(response)});
return false;
}
</script>
|
Can you try this? *just replace the secondary script I posted with this one, leave the loading of jquery in there and add the onsubmit attribute to your form*
|
|
Back to top |
|
 |
|
Posted: Fri, 17th Aug 2012 02:04 Post subject: |
|
 |
done. still redirecting me to my stupid thank you message
you sure i dont need to delete
echo "Thank You!" . " -" . "<a href='index.html'> Return Home</a>";
from mail.php or edit it or something ?
ASUS TUF B550M-PLUS | RYZEN 5600x | RTX 3060TI | 16GB DDR4
|
|
Back to top |
|
 |
|
Posted: Fri, 17th Aug 2012 02:09 Post subject: |
|
 |
no, that is the response from mail.php, that shouldn't be the problem.
|
|
Back to top |
|
 |
|
Posted: Fri, 17th Aug 2012 02:11 Post subject: |
|
 |
Can't check now my explorer exe crashed and won't restart )
|
|
Back to top |
|
 |
|
Posted: Fri, 17th Aug 2012 02:27 Post subject: |
|
 |
Fuck this "shit". One day to learn how to make and customize a contant form, another day to learn how to make my menus react how i want and customize them, another day to learn how to fix the header and the footer in position and readjust the layout and probably another day to figure out how to customize the confirmation popup for the form. This is going so slow, enough for today, im going to play something, will check tomorrow
ASUS TUF B550M-PLUS | RYZEN 5600x | RTX 3060TI | 16GB DDR4
|
|
Back to top |
|
 |
|
Posted: Fri, 17th Aug 2012 19:18 Post subject: |
|
 |
hei guys... hi
ASUS TUF B550M-PLUS | RYZEN 5600x | RTX 3060TI | 16GB DDR4
|
|
Back to top |
|
 |
|
Posted: Fri, 17th Aug 2012 20:07 Post subject: |
|
 |
ok i made it half way
Code: | <script type="text/javascript">
<!--
function popup(url)
{
var width = 300;
var height = 200;
var left = (screen.width - width)/2;
var top = (screen.height - height)/2;
var params = 'width='+width+', height='+height;
params += ', top='+top+', left='+left;
params += ', directories=no';
params += ', location=no';
params += ', menubar=no';
params += ', resizable=no';
params += ', scrollbars=no';
params += ', status=no';
params += ', toolbar=no';
newwin=window.open(url,'windowname5', params);
if (window.focus) {newwin.focus()}
return false;
}
// -->
</script> |
and added a href to the submit button
Code: | <a href="javascript: void(0)"
onclick="popup('popup.html')"><input style="width: 70px; height: 20px; cursor: pointer" type="submit" value="TRIMITE" class="submit_style" /></a>
|
ASUS TUF B550M-PLUS | RYZEN 5600x | RTX 3060TI | 16GB DDR4
|
|
Back to top |
|
 |
|
Posted: Fri, 17th Aug 2012 20:24 Post subject: |
|
 |
Yey i found exactly what i wanted
Code: | <script type="text/javascript">
var popup2 = new Popup();
popup2.autoHide = false;
popup2.content = 'This DIV will not close automatically!<br><br><a href="#" onclick="'+popup2.ref+'.hide();return false;">Click here to close</a>';
popup2.width=200;
popup2.height=200;
popup2.style = {'border':'3px solid black','backgroundColor':'yellow'};
</script>
|
Code: | <a href="#" onclick="popup2.show();return false;"><input style="width: 70px; height: 20px; cursor: pointer" type="submit" value="TRIMITE" class="submit_style" /></a> |
Edit: this one doesnt work damit
ASUS TUF B550M-PLUS | RYZEN 5600x | RTX 3060TI | 16GB DDR4
|
|
Back to top |
|
 |
|
Posted: Fri, 17th Aug 2012 22:28 Post subject: |
|
 |
wow this is harder than i thought..
i get the popup window when i click submit
but i also get redirected thanks to
echo "Thank You!" . " -" . "<a href='index.html'> Return Home</a>";
how do i get rid of this fucking line ??
puuuuuummmmpyyy
ASUS TUF B550M-PLUS | RYZEN 5600x | RTX 3060TI | 16GB DDR4
|
|
Back to top |
|
 |
|
|
Back to top |
|
 |
|
Posted: Sat, 18th Aug 2012 01:25 Post subject: |
|
 |
ok bastards i've done it
$mailheader = "From: $email \r\n"; header("Location: thankyou.html");
and made a duplicate contact.html named thankyou.html with the overlay function on
Code: | <script type="text/javascript">
function overlay() {
el = document.getElementById("overlay");
el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
}
window.onload=overlay;
</script>
|
huzaaa !!! im a genius
edit: ..actually thats not what i wanted but.. pff.. whatever it works
ASUS TUF B550M-PLUS | RYZEN 5600x | RTX 3060TI | 16GB DDR4
|
|
Back to top |
|
 |
Roach_666
Posts: 1299
Location: Hell in its Alpha Build
|
Posted: Sat, 18th Aug 2012 08:59 Post subject: |
|
 |
|
|
Back to top |
|
 |
Page 1 of 1 |
All times are GMT + 1 Hour |