spudly1987 Posted February 17, 2014 Share Posted February 17, 2014 I have the following contact box, and I want to be able to make it so that when you click on Send, it will send the information to an email address. I'm not sure if this needs to be done with php or just adding something like mailto:example@example.com any assistance would be appreciated <body bgcolor="black"> <div id="form-wrapper" class="myform"> <form id="form" name="form" method="post" action="index.html"> <p>For Fan Mail And Other Fun Things, Contact Me Here.</p> <label for="name">Name <span class="small">(Required)</span> </label> <input type="text" name="name" id="name" /> <label for="email">E-mail Address <span class="small">(Required)</span> </label> <input type="text" name="email" id="email" /> <label for="subject">Subject <span class="small">(Required)</span> </label> <input type="text" name="subject" id="subject" /> <label for="message">Message <span class="small">(Required)</span> </label> <textarea name="message" id="message" rows="5"></textarea> <button type="submit">Send</button> <div class="spacer"></div> </form> </div> </body> Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/ Share on other sites More sharing options...
fastsol Posted February 17, 2014 Share Posted February 17, 2014 You would need to either use php to process it or you can use ajax to send it without refreshing. Here is a tutorial on the ajax method that works really slick. http://www.youtube.com/watch?v=GrycH6F-ksY Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469237 Share on other sites More sharing options...
spudly1987 Posted February 20, 2014 Author Share Posted February 20, 2014 Okay so I think i'm missing something but not quite sure. I have the following contact form <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="ContactMe.php" /> <title>Contact Me</title> <style> body{font-family:verdana, arial, helvetica, sans-serif; font-size:14px; } p, h1, form, button{border:0; margin:0; padding:0;} .spacer{clear:both; height:1px;} /* ----------- My Form ----------- */ .myform{ margin:0 auto; width:509px; padding:14px; } /* ----------- form-wrapper ----------- */ #form-wrapper{ background: none repeat scroll 0 0 #C6C6C6; border: 2px solid #8B8B8B; border-radius: 10px; -moz-border-radius: 10px; -op-border-radius: 10px; -webkit-border-radius: 10px; } #form-wrapper h1 { font-weight:bold; margin-bottom:8px; } #form-wrapper p{ font-size:11px; color:#666666; margin-bottom:20px; border-bottom:solid 1px #7E7E7E; padding-bottom:10px; } #form-wrapper label{ display:block; font-weight:bold; text-align:right; width:193px; float:left; } #form-wrapper .small{ color:red; display:block; font-size:11px; font-weight:normal; text-align:right; width:193px; } #form-wrapper input,#form-wrapper textarea{ float:left; border:solid 1px #aacfe4; width:284px; margin:2px 0 20px 10px; border-radius: 15px; -moz-border-radius: 15px; -op-border-radius: 15px; -webkit-border-radius: 15px; font-size: 14px; } #form-wrapper input{ height: 25px; padding: 4px 10px; } #form-wrapper textarea{ padding: 10px 10px; overflow: auto; } /* ----------- Form Button ----------- */ #form-wrapper button { background: #2c3e4a; background: -webkit-gradient(linear, left top, left bottom, from(#919496), to(#2c3e4a)); background: -webkit-linear-gradient(top, #919496, #2c3e4a); background: -moz-linear-gradient(top, #919496, #2c3e4a); background: -ms-linear-gradient(top, #919496, #2c3e4a); background: -o-linear-gradient(top, #919496, #2c3e4a); padding: 5px 10px; -webkit-border-radius: 15px; -moz-border-radius: 15px; border-radius: 15px; margin-left: 315px; color: white; font-size: 20px; text-decoration: none; vertical-align: middle; } #form-wrapper button:hover { background: #3d4b54; color: #ccc; } </style> </head> <body bgcolor="black"> <div id="form-wrapper" class="myform"> <form id="form" name="form" method="post" action="index.html"> <p>For Fan Mail And Other Fun Things, Contact Me Here.</p> <label for="name">Name <span class="small">(Required)</span> </label> <input type="text" name="name" id="name" /> <label for="email">E-mail Address <span class="small">(Required)</span> </label> <input type="text" name="email" id="email" /> <label for="subject">Subject <span class="small">(Required)</span> </label> <input type="text" name="subject" id="subject" /> <label for="message">Message <span class="small">(Required)</span> </label> <textarea name="message" id="message" rows="5"></textarea> <button type="submit" onclick="ContactMe.php">Send</button> <div class="spacer"></div> </form> </div> </body> </html> I also created a php form for the emailing <?php /* Subject and Email Variables */ $emailSubject = 'Content Ordering!'; $webMaster = 'spudly1987@gmail.com'; /* Gathering Data Variables */ $nameField = $_POST('name'); $emailField = $_POST('email'); $subjectField = $_POST('subject'); $messageField = $_POST('message'); $body = <<<EOD <br><hr><br> Name: $name <br> Email: $email <br> Subject: $subject <br> Message: $message <br> EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <html> <head> <title>Untitled Document</title> </head> <body> <center>Thank you for your submission, I will respond back to you shortly.</center> </body> </html> EOD; echo "$theResutls"; ?> and i have the results page i would like for it to post when completed <html> <head> <title>Untitled Document</title> </head> <body> <center>Thank you for your submission, I will respond back to you shortly.</center> </body> </html> How ever something is not being linked or set correctly any help would be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469734 Share on other sites More sharing options...
fastsol Posted February 20, 2014 Share Posted February 20, 2014 Your form is posting to a html page which can't process the php. Also I have a nice prebuilt contact form that uses ajax and phpmailer to send which will work much better. It's free to use here JD Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469740 Share on other sites More sharing options...
spudly1987 Posted February 20, 2014 Author Share Posted February 20, 2014 Okay I changed the following Action from index.html to my contactme.php page <form id="form" name="form" method="post" action="ContactMe.php"> and now getting the following error Fatal error: Function name must be a string in /srv/disk9/1487284/www/modelcontent.eu.pn/ContactMe.php on line 10 Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469741 Share on other sites More sharing options...
fastsol Posted February 20, 2014 Share Posted February 20, 2014 You need [] around the post vars not () $_POST('name'); // BAD $_POST['name']; // GOOD Change it for all your other vars too. Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469744 Share on other sites More sharing options...
spudly1987 Posted February 20, 2014 Author Share Posted February 20, 2014 Okay I changed that, now I'm no longer getting the error message, but now its just a blank white screen, and nothing has been emailed yet Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469745 Share on other sites More sharing options...
fastsol Posted February 20, 2014 Share Posted February 20, 2014 Put this after the opening php tag and see if it gives you any other errors. error_reporting(E_ALL); Depending on if this is on your local host or a paid hosting account, you may also need to turn on error reporting in the php.ini file. If it's not on, the line above won't do any good. Also if you're on localhost, do you have a mail server setup? If not then t won't send mail anyway. Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469747 Share on other sites More sharing options...
spudly1987 Posted February 20, 2014 Author Share Posted February 20, 2014 (edited) I'm using a hosting site of http://freehostingeu.com I have all of my files uploaded on to that site. my direct link to the site is http://modelcontent.eu.pn and currently I'm just testing it with my g-mail email address. And also another issue i'm trying to fix, is the Spoil Me page is not loading up for some reason Edited February 20, 2014 by spudly1987 Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469749 Share on other sites More sharing options...
fastsol Posted February 20, 2014 Share Posted February 20, 2014 Are you Ashley? I would guess the reason that the spoil page is not loading is cause you seem to name your files with uppercase letters but on the spoil.html it's all lowercase, so the server can't find that file, hence the 404 page not found error. Your spelled results wrong echo "$theResutls"; Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469751 Share on other sites More sharing options...
fastsol Posted February 20, 2014 Share Posted February 20, 2014 Be careful with this site, most hosts do not like porn sites on their servers unless you are paying for a private server with them. Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469752 Share on other sites More sharing options...
spudly1987 Posted February 20, 2014 Author Share Posted February 20, 2014 okay when I click on send i am now getting the following post Notice: Undefined variable: name in /srv/disk9/1487284/www/modelcontent.eu.pn/ContactMe.php on line 19Notice: Undefined variable: email in /srv/disk9/1487284/www/modelcontent.eu.pn/ContactMe.php on line 20Notice: Undefined variable: message in /srv/disk9/1487284/www/modelcontent.eu.pn/ContactMe.php on line 21Notice: Undefined variable: email in /srv/disk9/1487284/www/modelcontent.eu.pn/ContactMe.php on line 24 Thank you for your submission, I will respond back to you shortly. Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469754 Share on other sites More sharing options...
spudly1987 Posted February 20, 2014 Author Share Posted February 20, 2014 okay now i got all those errors to go away now I actually have to get it to send, to the email Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469755 Share on other sites More sharing options...
fastsol Posted February 20, 2014 Share Posted February 20, 2014 Are you sure your host allows email sending, many of the free hosts limit many functions. Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469756 Share on other sites More sharing options...
spudly1987 Posted February 20, 2014 Author Share Posted February 20, 2014 I'll have to double check on that now i have to verify and find out why my spoil page is not working. Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469762 Share on other sites More sharing options...
spudly1987 Posted February 20, 2014 Author Share Posted February 20, 2014 i've double checked and triple checked the links and targets and can't find anything wrong with the spoil me button Quote Link to comment https://forums.phpfreaks.com/topic/286258-mailto-onclick-send/#findComment-1469765 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.