ieuan11 Posted November 3, 2010 Share Posted November 3, 2010 Hi guys i am building a tab that fixes to the screen and follows the screen i have sucess with this and it woks fine. i just need someone to wirte the php code for me as im am usless with it i have had a few attempts now and cant work it out. would very very much appreciate it if someone could help me. Thanks =D (function($){ //define the new for the plugin ans how to call it $.fn.contactable = function(options) { //set default options var defaults = { name: 'Name', email: 'Email', message : 'Message', recipient : 'test@test.co.uk', subject : 'A contactable message', recievedMsg : 'Thank you for your information, we will contact you as soon as possible.', notRecievedMsg : 'Sorry but your message could not be sent, try again later', disclaimer: 'Please feel free to get in touch,<br/>we value your feedback' }; //call in the default otions var options = $.extend(defaults, options); var contactShowStatus =1; //act upon the element that is passed into the design return this.each(function(options) { //construct the form $(this).html('<div id="contactable"></div><div id="contactForm" class="feedContainer"><a id="close_feedback" title="Close"><img src="images/btn-close.png" border="0" alt="Close" class="close" /></a><div class="topCrv"></div><div class="leftHand"><div class="leftshad"><div class="rightHand"><div class="rightshad"><div class="gradient"><form id="contactFormId" method="" action=""><div id="loading">Please Wait..<br><img src="plugin-images/ajax-loader.gif" border="0"/></div><div class="holder"><input type="hidden" id="recipient" name="recipient" value="'+defaults.recipient+'" /><input type="hidden" id="subject" name="subject" value="'+defaults.subject+'" /><label ><input type="text" id="name" name="name" /></label><label><input type="text" id="email" name="email" /></label><label><textarea id="comment" name="comment"></textarea></label><label><input type="submit" name="Submit" value="SEND" class="btn" /><span style=" padding-top:4px;">'+defaults.disclaimer+'</span></label></div></form><p class="thankNote" id="callback"></p></div></div></div></div></div><div class="botCrv"></div></div>'); $('#contactFormId #name').example('Name'); $('#contactFormId #email').example('Email'); $('#contactFormId #comment').example('Message'); //show / hide function function contactShow() { $('#overlay').css({display: 'block'}); $('div#contactable').animate({"marginLeft": "-=5px"}, "fast"); $('#contactForm').animate({"marginLeft": "-=0px"}, "fast"); $('div#contactable').animate({"marginLeft": "+=523px"}, "slow"); $('#contactForm').animate({"marginLeft": "+=520px"}, "slow"); $('.feedContainer .close').css({right: '-4px'}); contactShowStatus = 0; } function contactHide() { $('#contactForm').animate({"marginLeft": "-=520px"}, "slow"); $('div#contactable').animate({"marginLeft": "-=523px"}, "slow").animate({"marginLeft": "+=5px"}, "fast"); $('#overlay').css({display: 'none'}); $('.feedContainer .close').css({right: '0px'}); contactShowStatus =1; } $('div#contactable').click( function() { if(contactShowStatus==1) contactShow(); else contactHide(); }); $('a#close_feedback').click(function() { contactHide(); } ); //validate the form $("#contactFormId").validate({ //set the rules for the fild names rules: { name: { required: true, minlength: 2 }, email: { required: true, email: true }, comment: { required: true } }, //set messages to appear inline messages: { name: "Please enter your name", email: "Please enter your email", comment: "Please enter your Message" }, submitHandler: function() { $('.holder').hide(); $('#loading').show(); $.get('mail.php',{recipient:$('#recipient').val(), subject:$('#subject').val(), name:$('#name').val(), email:$('#email').val(), comment:$('#comment').val()}, function(data){ $('#loading').css({display:'none'}); $('.holder').show(); //document.forms['contactFormId'].reset() name:$('#name').val(''); email:$('#email').val(''); comment:$('#comment').val(''); if( data == 'success') { $('#callback').show().append(defaults.recievedMsg); } else { $('#callback').show().append(defaults.notRecievedMsg); } }); } }); }); }; //end the plugin call })(jQuery); Link to comment Share on other sites More sharing options...
Fmdpa Posted November 3, 2010 Share Posted November 3, 2010 First, please edit your post and change " ". Also please break up that one long line into shorter lines. It will make it easier to view, so we can help you. Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 First, please edit your post and change " ". Also please break up that one long line into shorter lines. It will make it easier to view, so we can help you.well its abit late now iv'e already posted it and i don't know how to change it even if i can change it as iv'e been using these forums for 1 hour...The code is there what wrong with that? I just relly need someone to help me..but i shall use [code] next time i use the forums thanks anyways.. Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 Really need to get this done soon so i can move on...Would really appreciate it. Link to comment Share on other sites More sharing options...
thescientist Posted November 3, 2010 Share Posted November 3, 2010 you can go back and edit your posts. I agree with Fmdpa that codebox makes it harder to read, as reader vertically longer is more intuitive than reading horizontally (especially with code).you also say you need help, but haven't said what you need help with. What are you trying to do? (note, no one here is just going to do it for you. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 3, 2010 Share Posted November 3, 2010 We don't really just write entire scripts for people, but if you want to post the PHP code you've got we can help you troubleshoot and expand it. You may also want to have that form submit via post instead of get, there is a limit to how much data can be sent through the querystring. Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 We don't really just write entire scripts for people, but if you want to post the PHP code you've got we can help you troubleshoot and expand it. You may also want to have that form submit via post instead of get, there is a limit to how much data can be sent through the querystring.okay sure here it is <?php //declare our assets $name = stripcslashes($_post['name']); $emailAddr = stripcslashes($_post['email']); $comment = stripcslashes($_post['comment']); $subject = stripcslashes($_post['subject']); $contactMessage = "Message: $comment \r \n From: $name \r \n Reply to: $emailAddr"; //validate the email address on the server side if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $emailAddr) ) { //if successful lets send the message mail('ieuan.marlowe@hotmail.co.uk', $subject, $contactMessage); echo('success'); //return success callback } else { echo('An invalid email address was entered'); //email was not valid }?> As i said im really bad with PHP so don't expect anything amazing. Thanks. Link to comment Share on other sites More sharing options...
justsomeguy Posted November 3, 2010 Share Posted November 3, 2010 PHP variables names are case-sensitive, so $_POST is not the same as $_post. But your form isn't using post, it's using get. You can add this to your PHP code to have it print the data it receives in $_POST:print_r($_POST);Since this is ajax that output will just appear on the page somewhere, but it will at least tell you if the script is receiving anything in $_POST and, if so, what it's getting. Also, a carriage return/line break sequence shouldn't have a space between them. Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 PHP variables names are case-sensitive, so $_POST is not the same as $_post. But your form isn't using post, it's using get. You can add this to your PHP code to have it print the data it receives in $_POST:print_r($_POST);Since this is ajax that output will just appear on the page somewhere, but it will at least tell you if the script is receiving anything in $_POST and, if so, what it's getting. Also, a carriage return/line break sequence shouldn't have a space between them.okay but iv'e tried putting them the same case but its not making a diffrence i know it's alot for me to ask but would you be able to edit my PHP i would appreciate it alot. Thanks. Link to comment Share on other sites More sharing options...
thescientist Posted November 3, 2010 Share Posted November 3, 2010 did you make $_post $_POST? like JSG said your form is using $_GET, so you should be using that instead of $_POST (unless you've since changed it). It is helpful to us that you post your code as you make changes to it so we can specifically know what you've done. Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 okay this is what i have...the form is working how it should but the e-mail is not coming through on my account so there obviosly is still a problem..=/here we go JQuery: (function($){ //define the new for the plugin ans how to call it $.fn.contactable = function(options) { //set default options var defaults = { name: 'Name', email: 'Email', message : 'Message', subject : 'A contactable message', recievedMsg : 'Thankyou for your message', notRecievedMsg : 'Sorry but your message could not be sent, try again later', disclaimer: 'Please feel free to get in touch, we value your feedback', hideOnSubmit: true }; //call in the default otions var options = $.extend(defaults, options); //act upon the element that is passed into the design return this.each(function(options) { //construct the form $(this).html('<div id="contactable"></div><form id="contactForm" method="" action=""><div id="loading"></div><div id="callback"></div><div class="holder"><p><label for="name">Name <span class="red"> * </span></label><br /><input id="name" class="contact" name="name" /></p><p><label for="email">E-Mail <span class="red"> * </span></label><br /><input id="email" class="contact" name="email" /></p><p><label for="comment">Your Feedback <span class="red"> * </span></label><br /><textarea id="comment" name="comment" class="comment" rows="4" cols="30" ></textarea></p><p><input class="submit" type="submit" value="Send"/></p><p class="disclaimer">'+defaults.disclaimer+'</p></div></form>'); //show / hide function $('div#contactable').toggle(function() { $('#overlay').css({display: 'block'}); $(this).animate({"marginLeft": "-=5px"}, "fast"); $('#contactForm').animate({"marginLeft": "-=0px"}, "fast"); $(this).animate({"marginLeft": "+=387px"}, "slow"); $('#contactForm').animate({"marginLeft": "+=390px"}, "slow"); }, function() { $('#contactForm').animate({"marginLeft": "-=390px"}, "slow"); $(this).animate({"marginLeft": "-=387px"}, "slow").animate({"marginLeft": "+=5px"}, "fast"); $('#overlay').css({display: 'none'}); }); //validate the form $("#contactForm").validate({ //set the rules for the fild names rules: { name: { required: true, minlength: 2 }, email: { required: true, email: true }, comment: { required: true } }, //set messages to appear inline messages: { name: "", email: "", comment: "" }, submitHandler: function() { $('.holder').hide(); $('#loading').show(); $.GET('mail.php',{subject:$('#subject').val(), name:$('#name').val(), email:$('#email').val(), comment:$('#comment').val()}, function(data){ $('#loading').css({display:'none'}); if( data == 'success') { $('#callback').show().append(defaults.recievedMsg); if(defaults.hideOnSubmit == true) { //hide the tab after successful submition if requested $('#contactForm').animate({dummy:1}, 2000).animate({"marginLeft": "-=450px"}, "slow"); $('div#contactable').animate({dummy:1}, 2000).animate({"marginLeft": "-=447px"}, "slow").animate({"marginLeft": "+=5px"}, "fast"); $('#overlay').css({display: 'none'}); } } else { $('#callback').show().append(defaults.notRecievedMsg); } }); } }); }); };})(jQuery); PHP: <?php //declare our assets $name = stripcslashes($_GET['name']); $emailAddr = stripcslashes($_GET['email']); $comment = stripcslashes($_GET['comment']); $subject = stripcslashes($_GET['subject']); $contactMessage = "Message: $comment \r \n From: $name \r \n Reply to: $emailAddr"; //validate the email address on the server side if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $emailAddr) ) { //if successful lets send the message mail('ieuan.marlowe@hotmail.co.uk', $subject, $contactMessage); echo('success'); //return success callback } else { echo('An invalid email address was entered'); //email was not valid }?> Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 Can Anyone spot any errors in my code? Link to comment Share on other sites More sharing options...
thescientist Posted November 3, 2010 Share Posted November 3, 2010 it appears there's no action or method set to the form: $(this).html('<div id="contactable"></div><form id="contactForm" method="" action="" try adding the name of the PHP file to 'action', and then add get as the method.http://www.w3schools.com/html/html_forms.asp Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 okay now it's asking me if i want to save the file what shall i do next? Link to comment Share on other sites More sharing options...
thescientist Posted November 3, 2010 Share Posted November 3, 2010 sorry, I don't get the question. I'm not sure what it has to do with my suggestion. Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 no my bad..i have done what you have asked me to do now it wants me to save the file? it's not posting Link to comment Share on other sites More sharing options...
thescientist Posted November 3, 2010 Share Posted November 3, 2010 are you running this on a webserver? (like WAMP/MAMP) or on a hosting site? Basically, can you run php to begin with? Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 are you running this on a webserver? (like WAMP/MAMP) or on a hosting site? Basically, can you run php to begin with?yes here look http://www.imgames.co.uk/its hosting on 1and1 with php Link to comment Share on other sites More sharing options...
thescientist Posted November 3, 2010 Share Posted November 3, 2010 hmm...this page doesn't have that change to the form. it still shows empty strings for method and action Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 hmm...this page doesn't have that change to the form. it still shows empty strings for method and actionthats because iv'e tried with and without and im trying everything right now iv'e been trying to work it out for the past 6 hours. I will do it =D Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 okay have a look at it now iv'e added them back in again Link to comment Share on other sites More sharing options...
thescientist Posted November 3, 2010 Share Posted November 3, 2010 sorry, I see what you mean now about that line you quoted. Take out my suggestions (method, action).ok, perhaps its in the PHP. Something to consider. If you upload a test php page, and all it has is this: <?phpecho phpinfo();?> it will tell you what version of PHP your host is running, because the function you are using in your condition check eregi is depricated in PHP5.3 and higher.http://php.net/manual/en/function.eregi.php So:1) upload the test page with the code snippet I showed you and see what version of PHP you are running2) regardless, try changing your mail.php code to this, just to see if its even sending mail to you at all. <?php//declare our assets $name = stripcslashes($_GET['name']);$emailAddr = stripcslashes($_GET['email']);$comment = stripcslashes($_GET['comment']);$subject = stripcslashes($_GET['subject']); $contactMessage = "Message: $comment \r \n From: $name \r \n Reply to: $emailAddr";mail('ieuan.marlowe@hotmail.co.uk', $subject, $contactMessage);?> see if any of that gives us some answers. sorry about the confusion earlier. I think we're almost there, though. Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 okay Link to comment Share on other sites More sharing options...
ieuan11 Posted November 3, 2010 Author Share Posted November 3, 2010 okay http://www.imgames.co.uk/default.php Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.