SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Apr 2013
    0 Post(s)
    0 Thread(s)

    Help, I'm Stupid

    I'm just setting up a small contact form, but seeing as my knowledge of PHP is all through copypasta, I need help. Everything was sending fine until I tried to set up an HTML email format... now the code just shows up in my email without any of the values filled in. In addition to fixing that, I was hoping to redirect users to a thank you page, and perhaps make the error boxes popups without reloading the entire form (Javascript?), and bring democracy to Cuba. If this is not possible, just help with the HTML thing would be much appreciated. Code:

    PHP Code:
    $to '---removed---';
    $subject 'Contact';
    $from_name $_POST['name'];
    $from_email $_POST['email'];
    $from_phone $_POST['phone'];
    $comments $_POST['comments'];
    $robotest $_POST['robotest'];
    $error "Are you a robot?";
    $from_name && $from_email or $from_phone && $comments){

    $headers 'From: $_POST['$from_name']\r\n';
    $headers .= 'Reply-To: $_POST['$from_email']\r\n';
    $headers .= 'CC: ---removed---\r\n';
    $headers .= 'MIME-Version: 1.0\r\n';
    $headers .= 'Content-Type: text/html; charset=ISO-8859-1\r\n';
    $message '<html><body>';
    $message .= '<font size="10">---Title---</font> $Date $Time';
    $message .= '<hr width="100%">';
    $message .= '<table cellpadding="2" cellspacing="0" border="0">';
    $message .= '<tr><td width="250">Name:</td><td><b>$from_name</b></td></tr>';
    $message .= '<tr><td width="250">E-mail Address:</td><td>$from_email</td></tr>';
    $message .= '<tr><td width="250">Phone Number:</td><td><b>$phone</b></td></tr>';
    $message .= '</table>';
    $message .= '<hr width="100%">';
    $message .= '<table cellpadding="2" cellspacing="0" border="0">';
    $message .= '<tr><td width="250">Comments:</td><td><b>$comments</b></td></tr>';
    $message .= '</body></html>';

    $header "From: $from_name <$from_email>";

    $success "Thank you for contacting us. If a response is required, someone will 

    get back to you in one business day."
    $error "There was a problem sending the email.";
    $error "Please enter your name, message and email or phone number.";
    '<div class="msg error">'.$error.'</div>';
    '<div class="msg success">'.$success.'</div>';

    HTML Code:
    <form method="post" action="">
    <span class="contact"><b>Contact Us</b></span><br>
    <table cellpadding="0" cellspacing="0" border="0">
    <td width="70px" valign="top" class="contact" align="left">Name:</td>
    <td width="20px"></td>
    <td align="left"><input type="text" name="name" id="name" size="35" /><br><br></td>
    <td width="70px" valign="top" class="contact" align="left">Email:</td>
    <td width="20px"></td>
    <td align="left"><input type="text" name="email" id="email" size="35" /><br><br></td>
    <td width="70px" valign="top" class="contact" align="left">Phone:</td>
    <td width="20px"></td>
    <td align="left"><input type="text" name="phone" id="phone" size="25" /><br><br></td>
    <td width="70px" valign="top" class="contact" align="left">Message:</td>
    <td width="20px"></td>
    <td align="left"><textarea name="comments" id="comments" rows="7" cols="70" maxlength="2000"></textarea><br><br></td>
    <!-- The following field is for robots only, invisible to humans: -->
    <p class="robotic" id="pot">
    <label>If you're human leave this blank:</label>
    <input name="robotest" type="text" id="robotest" class="robotest" />
    <td width="70px"></td>
    <td width="20px"></td>
    <td align="left"><input type="submit" name="submit" value="Submit"></td>
    Last edited by cpradio; Apr 1, 2013 at 15:52. Reason: Added php and html tags


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts