Hi, How to revise the php code so that it could fits the subject for e-mail?

Thanks.

<?php
    require_once('recaptchalib.php');
    $name = strip_tags(@$_POST['name']);
    $email = str_replace(" ", "", strip_tags(@$_POST['email']));
    $phone = str_replace(" ", "", strip_tags(@$_POST['phone']));
    $message = strip_tags(@$_POST['message']);
    if (@$_POST['submit']) {
    if ($name&&$email&&$phone&&$message) {
    if (is_numeric($phone)) {
    $privatekey = "6LfjvdcSAAAAAHNcKjYO5DhTNefxYZHYcfhtrvGC";
    $resp = recaptcha_check_answer($privatekey,
    $_SERVER["REMOTE_ADDR"],
    $_POST["recaptcha_challenge_field"],
    $_POST["recaptcha_response_field"]);
    if (!$resp->is_valid) {
    //What happens when the CAPTCHA was entered incorrectly
    echo "The reCAPTCHA wasn't entered correctly.";
    } else {
    //Your code here to handle a successful verification
    ini_set("SMTP", "smtp.mail.yahoo.com");
    $body = "
    Name: ".$name."
    Phone: ".$phone."
    Email: ".$email."\n\n
    ".$message;
    mail("davy_yg@yahoo.com", "Message from Innovation Website", $body, "From: ".$email);
    echo "Your message has been sent, we will get back to your shortly.";
    $name = trim("");
    $email = trim("");
    $phone = trim("");
    $message = trim("");
    }
    }
    else
    echo "There should only be numbers in your phone number.";
    }
    else
    echo "Please fill in <b>all</b> the fields!";
    }
    ?>

CONTACT US


<div id="form">
<table border="0">
<tr>
<td>NAMA: </td>
<td><input type="text" name="nama" value="<?php echo $name; ?>"></td> <br>
</tr>
<tr>
<td>EMAIL: </td>
<td><input type="text" name="email" value="<?php echo $email; ?>"></td> <br>
</tr>
<tr>
<td>TELEPHONE: </td>
<td><input type="text" name="telephone" value="<?php echo $phone; ?>"></td> <br>
</tr>
<tr>
<td>SUBJECT: </td>
<td><input type="text" name="subject"></td> <br>
</tr>
<tr>
<td>FEEDBACK: </td>
<td><textarea name="feedback" value="<?php echo $pesan; ?>"></textarea></td> <br><br>
</tr>
<tr>
<td></td>
<td><br><input type="submit" class="button" value="SUBMIT"><br><br></td>
</tr>

</table>
</div>

Recommended Answers

All 2 Replies

Your question makes no sense.

Where did the code come from? Was it written by yourself

someone give it to me. I just do not know how to add revision to it so that it stays working.

Does this seems right? (I haven't tested as I revise them offline - the online server is not yet ready)

    <?php
    require_once('recaptchalib.php');
    $name = strip_tags(@$_POST['name']);
    $email = str_replace(" ", "", strip_tags(@$_POST['email']));
    $phone = str_replace(" ", "", strip_tags(@$_POST['phone']));
    $subject = strip_tags(@$_POST['subject']);
    $message = strip_tags(@$_POST['message']);
    if (@$_POST['submit']) {
    if ($name&&$email&&$phone&&$message&&subject) {
    if (is_numeric($phone)) {
    $privatekey = "6LfjvdcSAAAAAHNcKjYO5DhTNefxYZHYcfhtrvGC";
    $resp = recaptcha_check_answer($privatekey,
    $_SERVER["REMOTE_ADDR"],
    $_POST["recaptcha_challenge_field"],
    $_POST["recaptcha_response_field"]);
    if (!$resp->is_valid) {
    //What happens when the CAPTCHA was entered incorrectly
    echo "The reCAPTCHA wasn't entered correctly.";
    } else {
    //Your code here to handle a successful verification
    ini_set("SMTP", "smtp.mail.yahoo.com");
    $body = "
    Name: ".$name."
    Phone: ".$phone."
    Email: ".$email."\n\n
    ".$subject."\n\n".$message;
    mail("davy_yg@yahoo.com", "Message from Innovation Website", $body, "From: ".$email);
    echo "Your message has been sent, we will get back to your shortly.";
    $name = trim("");
    $email = trim("");
    $phone = trim("");
    $subject = trim("");
    $message = trim("");
    }
    }
    else
    echo "There should only be numbers in your phone number.";
    }
    else
    echo "Please fill in <b>all</b> the fields!";
    }
    ?>
    CONTACT US
    <div id="form">
    <table border="0">
    <tr>
    <td>NAMA: </td>
    <td><input type="text" name="nama" value="<?php echo $name; ?>"></td> <br>
    </tr>
    <tr>
    <td>EMAIL: </td>
    <td><input type="text" name="email" value="<?php echo $email; ?>"></td> <br>
    </tr>
    <tr>
    <td>TELEPHONE: </td>
    <td><input type="text" name="telephone" value="<?php echo $phone; ?>"></td> <br>
    </tr>
    <tr>
    <td>SUBJECT: </td>
    <td><input type="text" name="subject"></td> <br>
    </tr>
    <tr>
    <td>FEEDBACK: </td>
    <td><textarea name="feedback" value="<?php echo $pesan; ?>"></textarea></td> <br><br>
    </tr>
    <tr>
    <td></td>
    <td><br><input type="submit" class="button" value="SUBMIT"><br><br></td>
    </tr>
    </table>
    </div>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.