Jump to content

Definition-Designs

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Everything posted by Definition-Designs

  1. My error is 'Warning: implode() [function.implode]: Invalid arguments passed in /home/definiti/public_html/contact.php on line 73' Im not sure how to fix this error, as I looked online and it says that my implode() has the right layout too it.. Line 73 in my code (I took the HTML code out) is this line; $message = implode("<br>\n", $messages); My whole code is; <?php # PHP Copyright 2007, Thomas Boutell and Boutell.Com, Inc. # Edited by Definition Designs. $recipient = 'defenitiondesigns@googlemail.com'; $serverName = 'www.definition-designs.co.uk'; if ($_POST['send']) { sendMail(); } elseif (($_POST['cancel']) || ($_POST['continue'])) { redirect(); } else { displayForm(false); } function displayForm($messages) { global $login; $escapedEmail = htmlspecialchars($_POST['email']); $escapedRealName = htmlspecialchars($_POST['realname']); $escapedSubject = htmlspecialchars($_POST['subject']); $escapedBody = htmlspecialchars($_POST['body']); $returnUrl = $_POST['returnurl']; if (!strlen($returnUrl)) { $returnUrl = $_SERVER['HTTP_REFERER']; if (!strlen($returnUrl)) { $returnUrl = '/'; } } $escapedReturnUrl = htmlspecialchars($returnUrl); ?> <?php if (count($messages) > 0) { $message = implode("<br>\n", $messages); echo("<h4>$message</h4>\n"); } ?> <form method="POST" action="<?php echo $_SERVER['DOCUMENT_URL']?>"> <p> <b>Your</b> Email Address <input name="email" size="35" maxlength="35" value="<?php echo $escapedEmail?>"/> </p> <p> Your <b>Real</b> Name <input name="realname" size="35" maxlength="35" value="<?php echo $escapedRealName?>"/> </p> <p> Subject Of Your Message <input name="subject" size="35" maxlength="35" value="<?php echo $escapedSubject?>"/> </p> <p> <i>Please enter the text of your message in the field that follows.</i> </p> <textarea name="body" rows="10" cols="60"><?php echo $escapedBody?></textarea> <p> <input type="submit" name="send" value="Send Your Message"/> <input type="submit" name="cancel" value="Cancel - Never Mind"/> </p> <input type="hidden" name="returnurl" value="<?php echo $escapedReturnUrl?>"/> </form> <?php } function redirect() { global $serverName; $returnUrl = $_POST['returnurl']; $prefix = "http://$serverName/"; if (!beginsWith($returnUrl, $prefix)) { $returnUrl = "http://$serverName/"; } header("Location: $returnUrl"); } function beginsWith($s, $prefix) { return (substr($s, 0, strlen($prefix)) === $prefix); } function sendMail() { global $recipient; $messages = array(); $email = $_POST['email']; if (!preg_match("/^[\w\+\-\.\~]+\@[\-\w\.\!]+$/", $email)) { $messages[] = "That is not a valid email address. In format: You@something.com"; } $realName = $_POST['realname']; if (!preg_match("/^[\w\ \+\-\'\"]+$/", $realName)) { $messages[] = "The real name field must contain only alphanumeric characters, spaces and + or - signs."; } $subject = $_POST['subject']; if (preg_match('/^\s*$/', $subject)) { $messages[] = "Please specify a subject for your message. "; } $body = $_POST['body']; if (preg_match('/^\s*$/', $body)) { $messages[] = "Your message was blank. Fill out a message or Click Cancel to cancel message."; } if (count($messages)) { displayForm($messages); return; } mail($recipient, $subject, $body) or die("unable to send the mail!"); $escapedReturnUrl = htmlspecialchars($_POST['returnurl']); ?> <form method="POST" action="<?php echo $_SERVER['DOCUMENT_URL']?>"> <input type="submit" name="continue" value="Click Here To Continue"/> <input type="hidden" name="returnurl" value="<?php echo $escapedReturnUrl?>"/> </form> <?php } ?>
  2. I've debugged it, the mail variables are defined values. Ive echo'd it and it says it is sending. The mail() works on my server. The e-mail account is working as it can recieve mail from other sources. SMTP is activated on my hosting account. I cannot see why this doesn't work, my hosts are not viable to help me with my script troubles. Please, someome tell me why this still isnt sending mail on submit. It has worked on another server, but there must be a reason as to why it isnt working on mine.. <?php # PHP Copyright 2007, Thomas Boutell and Boutell.Com, Inc. # Edited by Definition Designs. $recipient = 'information@definition-designs.co.uk'; $serverName = 'www.definition-designs.co.uk'; if ($_POST['send']) { sendMail(); } elseif (($_POST['cancel']) || ($_POST['continue'])) { redirect(); } else { displayForm(false); } function displayForm($messages) { global $login; $escapedEmail = htmlspecialchars($_POST['email']); $escapedRealName = htmlspecialchars($_POST['realname']); $escapedSubject = htmlspecialchars($_POST['subject']); $escapedBody = htmlspecialchars($_POST['body']); $returnUrl = $_POST['returnurl']; if (!strlen($returnUrl)) { $returnUrl = $_SERVER['HTTP_REFERER']; if (!strlen($returnUrl)) { $returnUrl = '/'; } } $escapedReturnUrl = htmlspecialchars($returnUrl); ?> <html> <head> <title>Definition Designs - Web and Graphics Design</title> <meta name="Author" content="Joshua Martin" /> <meta name="Description" content="Definition Designs is the website of Web and Graphic Designer Joshua Martin" /> <div id="MailForm"> <?php if (count($messages) > 0) { $message = implode("<br>\n", $messages); echo("<h3>$message</h3>\n"); } ?> <form method="POST" action="<?php echo $_SERVER['DOCUMENT_URL']?>"> <p> <b>Your</b> Email Address <input name="email" size="35" maxlength="35" value="<?php echo $escapedEmail?>"/> </p> <p> Your <b>Real</b> Name <input name="realname" size="35" maxlength="35" value="<?php echo $escapedRealName?>"/> </p> <p> Subject Of Your Message <input name="subject" size="35" maxlength="35" value="<?php echo $escapedSubject?>"/> </p> <p> <i>Please enter the text of your message in the field that follows.</i> </p> <textarea name="body" rows="10" cols="60"><?php echo $escapedBody?></textarea> <p> <input type="submit" name="send" value="Send Your Message"/> <input type="submit" name="cancel" value="Cancel - Never Mind"/> </p> <input type="hidden" name="returnurl" value="<?php echo $escapedReturnUrl?>"/> </form> </body> </html> <?php } function redirect() { global $serverName; $returnUrl = $_POST['returnurl']; $prefix = "http://$serverName/"; if (!beginsWith($returnUrl, $prefix)) { $returnUrl = "http://$serverName/"; } header("Location: $returnUrl"); } function beginsWith($s, $prefix) { return (substr($s, 0, strlen($prefix)) === $prefix); } function sendMail() { global $recipient; $messages = array(); $email = $_POST['email']; if (!preg_match("/^[\w\+\-\.\~]+\@[\-\w\.\!]+$/", $email)) { $messages[] = "That is not a valid email address. Perhaps you left out the @something.com part? "; } $realName = $_POST['realname']; if (!preg_match("/^[\w\ \+\-\'\"]+$/", $realName)) { $messages[] = "The real name field must contain only alphabetical characters, numbers, spaces, and the + and - signs. We apologize for any inconvenience. "; } $subject = $_POST['subject']; if (preg_match('/^\s*$/', $subject)) { $messages[] = "Please specify a subject for your message. "; } $body = $_POST['body']; if (preg_match('/^\s*$/', $body)) { $messages[] = "Your message was blank. Did you mean to say something? Click the Cancel button if you do not wish to send a message. "; } if (count($messages)) { displayForm($messages); return; } mail($recipient, $subject, $body) or die("unable to send the mail!"); $escapedReturnUrl = htmlspecialchars($_POST['returnurl']); ?> <html> <head> <title>Definition Designs - Thank You</title> <link href="/stylesheet.css" rel="stylesheet" type="text/css"/> </head> <body> <div id="phpform"> <h1>Thank You</h1> <p> Thank you for contacting us! Your message has been sent. </p> <form method="POST" action="<?php echo $_SERVER['DOCUMENT_URL']?>"> <input type="submit" name="continue" value="Click Here To Continue"/> <input type="hidden" name="returnurl" value="<?php echo $escapedReturnUrl?>"/> </form> <?php } ?> </body> </html>
  3. Turns out it was my web hosting provider. They do not allow SMTP, so I shall be changing! Thanks for the help anyway, guys!
  4. } if (mail($recipient, $subject, $body, "From: $realName, $email")) { echo("<p>Message successfully sent!</p>"); echo("<p>$subject</p>"); echo("<p>$body</p>"); echo("<p>From: $realName, $email</p>"); echo("To: $recipient"); } else { echo("<p>Message delivery failed...</p>"); } I changed to code to that, filled it in, clickd submit and got this: I cant see why this is not sending! EDIT: It doesnt seem to be a problem with the account itself, as I can send mail from my hotmail to this account..
  5. Im not sure if this is an error on my E-Mail account end, or a problem with my code. Im a bit of a novice to PhP, and downloaded a Contact form script from the web, and played around with it a little. Now when the 'Submit' button is clicked, it echo's that the message has been sent, yet I do not recieve it in my e-mail account. Is this my account's fault, or a problem with my php? This is my code, I know it CAN be more efficient, but I will clean it up when it works. Thanks. <?php # PHP Copyright 2007, Thomas Boutell and Boutell.Com, Inc. # Edited by Definition Designs. $recipient = 'information@definition-designs.co.uk'; $serverName = 'www.definition-designs.co.uk'; if ($_POST['send']) { sendMail(); } elseif (($_POST['cancel']) || ($_POST['continue'])) { redirect(); } else { displayForm(false); } function displayForm($messages) { global $login; $escapedEmail = htmlspecialchars($_POST['email']); $escapedRealName = htmlspecialchars($_POST['realname']); $escapedSubject = htmlspecialchars($_POST['subject']); $escapedBody = htmlspecialchars($_POST['body']); $returnUrl = $_POST['returnurl']; if (!strlen($returnUrl)) { $returnUrl = $_SERVER['HTTP_REFERER']; if (!strlen($returnUrl)) { $returnUrl = '/'; } } $escapedReturnUrl = htmlspecialchars($returnUrl); ?> <html> <head> <title>Definition Designs - Web and Graphics Design</title> <meta name="Author" content="Joshua Martin" /> <meta name="Description" content="Definition Designs is the website of Web and Graphic Designer Joshua Martin" /> <link href="/stylesheet.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="/rollover.js"></script> </head> <body onLoad="MM_preloadImages('http://www.definition-designs.co.uk/Images/homeover.png')"> <div id="header"> <img src="http://www.definition-designs.co.uk/Images/header.png"/> </div> <div id="navigation"> <a href="http://www.definition-designs.co.uk/index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Home','','http://www.definition-designs.co.uk/Images/homeover.png',1)"><img src="http://www.definition-designs.co.uk/Images/homenotover.png" border="0" name="Home" id="Home" /></a> <a href="http://www.definition-designs.co.uk/about.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('About','','http://www.definition-designs.co.uk/Images/aboutover.png',1)"><img src="http://www.definition-designs.co.uk/Images/aboutnotover.png" border="0" name="About" id="About" /></a> <a href="http://www.definition-designs.co.uk/portfolio.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Portfolio','','http://www.definition-designs.co.uk/Images/portfolioover.png',1)"><img src="http://www.definition-designs.co.uk/Images/portfolionotover.png" border="0" name="Portfolio" id="Portfolio"/></a> <a href="http://www.definition-designs.co.uk/contact.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Contact','','http://www.definition-designs.co.uk/Images/contactover.png',1)"><img src="http://www.definition-designs.co.uk/Images/contactnotover.png" border="0" name="Contact" id="Contact"/></a> </div> <div id="mainContent2"> <div id="MailForminfo"> To contact me for a question, or to request one of my services, please fill out the contact form to the left.<br> <br> I will try to reply as soon as possible. <br> <br> Websites can take from 1 week to 1 month to create depending on the order, with Graphic design being more varied. </div> <div id="MailForm"> <?php if (count($messages) > 0) { $message = implode("<br>\n", $messages); echo("<h3>$message</h3>\n"); } ?> <form method="POST" action="<?php echo $_SERVER['DOCUMENT_URL']?>"> <p> <b>Your</b> Email Address <input name="email" size="35" maxlength="35" value="<?php echo $escapedEmail?>"/> </p> <p> Your <b>Real</b> Name <input name="realname" size="35" maxlength="35" value="<?php echo $escapedRealName?>"/> </p> <p> Subject Of Your Message <input name="subject" size="35" maxlength="35" value="<?php echo $escapedSubject?>"/> </p> <p> <i>Please enter the text of your message in the field that follows.</i> </p> <textarea name="body" rows="10" cols="60"><?php echo $escapedBody?></textarea> <p> <input type="submit" name="send" value="Send Your Message"/> <input type="submit" name="cancel" value="Cancel - Never Mind"/> </p> <input type="hidden" name="returnurl" value="<?php echo $escapedReturnUrl?>"/> </form> </body> </html> <?php } function redirect() { global $serverName; $returnUrl = $_POST['returnurl']; $prefix = "http://$serverName/"; if (!beginsWith($returnUrl, $prefix)) { $returnUrl = "http://$serverName/"; } header("Location: $returnUrl"); } function beginsWith($s, $prefix) { return (substr($s, 0, strlen($prefix)) === $prefix); } function sendMail() { global $recipient; $messages = array(); $email = $_POST['email']; if (!preg_match("/^[\w\+\-\.\~]+\@[\-\w\.\!]+$/", $email)) { $messages[] = "That is not a valid email address. Perhaps you left out the @something.com part? "; } $realName = $_POST['realname']; if (!preg_match("/^[\w\ \+\-\'\"]+$/", $realName)) { $messages[] = "The real name field must contain only alphabetical characters, numbers, spaces, and the + and - signs. We apologize for any inconvenience. "; } $subject = $_POST['subject']; $subject = preg_replace('/\s+/', ' ', $subject); if (preg_match('/^\s*$/', $subject)) { $messages[] = "Please specify a subject for your message. "; } $body = $_POST['body']; if (preg_match('/^\s*$/', $body)) { $messages[] = "Your message was blank. Did you mean to say something? Click the Cancel button if you do not wish to send a message. "; } if (count($messages)) { displayForm($messages); return; } if (mail($recipitent, $subject, $body, "From: $realName <$email>")) { echo("<p>Message successfully sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } $escapedReturnUrl = htmlspecialchars($_POST['returnurl']); ?> <html> <head> <title>Thank You</title> </head> <body> <h1>Thank You</h1> <p> Thank you for contacting us! Your message has been sent. </p> <form method="POST" action="<?php echo $_SERVER['DOCUMENT_URL']?>"> <input type="submit" name="continue" value="Click Here To Continue"/> <input type="hidden" name="returnurl" value="<?php echo $escapedReturnUrl?>"/> </form> <?php } ?> </div> </div> </body> </html>
×
×
  • 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.