Help me customize my contact form confirmation message
Page 1 of 1
Vikerness




Posts: 3616
Location: Brasov
PostPosted: 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:
 

and mail.php
 Spoiler:
 

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
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: 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


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
Vikerness




Posts: 3616
Location: Brasov
PostPosted: 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
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: 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*


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
Vikerness




Posts: 3616
Location: Brasov
PostPosted: 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
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Fri, 17th Aug 2012 02:09    Post subject:
no, that is the response from mail.php, that shouldn't be the problem.


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
PumpAction
[Schmadmin]



Posts: 26759

PostPosted: Fri, 17th Aug 2012 02:11    Post subject:
Can't check now my explorer exe crashed and won't restart )


=> NFOrce GIF plugin <= - Ryzen 3800X, 16GB DDR4-3200, Sapphire 5700XT Pulse
Back to top
Vikerness




Posts: 3616
Location: Brasov
PostPosted: 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
Vikerness




Posts: 3616
Location: Brasov
PostPosted: Fri, 17th Aug 2012 19:18    Post subject:
hei guys... hi


ASUS TUF B550M-PLUS | RYZEN 5600x | RTX 3060TI | 16GB DDR4
Back to top
Vikerness




Posts: 3616
Location: Brasov
PostPosted: 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
Vikerness




Posts: 3616
Location: Brasov
PostPosted: 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
Vikerness




Posts: 3616
Location: Brasov
PostPosted: 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
Vikerness




Posts: 3616
Location: Brasov
PostPosted: Sat, 18th Aug 2012 01:02    Post subject:
ok im getting to the end
got the right script
Code:
<script type="text/javascript">
function overlay() {
   el = document.getElementById("overlay");
   el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
}


a div
Code:
      <div id="overlay">
            <div>
                  <p>Content you want the user to see goes here.</p>
                  Click here to [<a href='#' onclick='overlay()'>close</a>]
             </div>
      </div>

and the correct mail.php
Code:
<?php $name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "kethisworld@yahoo.com";
$subject = "gaming-today.com message !!!";
$mailheader = "From: $email \r\n"; header("Location: contact.html"); // !!!!!
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Mersi" . " -" . "<a href='index.html' style='text-decoration:none;color:#cbbb9d;'> Inapoi </a>";
?>

i cant assign <a href='#' onclick='overlay()'>close</a> to the submit button as it gets processed before refreshing the page so i need to call this function after the refresh

how do i do it ??Smile)


ASUS TUF B550M-PLUS | RYZEN 5600x | RTX 3060TI | 16GB DDR4
Back to top
Vikerness




Posts: 3616
Location: Brasov
PostPosted: 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
PostPosted: Sat, 18th Aug 2012 08:59    Post subject:
Back to top
Page 1 of 1 All times are GMT + 1 Hour
NFOHump.com Forum Index - Programmers Corner
Signature/Avatar nuking: none (can be changed in your profile)  


Display posts from previous:   

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group