表单字段未被传递

时间:2014-03-06 18:30:30

标签: php jquery html forms

有些人可以帮助我处理此页面上的表单:http://riccipsych.com/referrals.php?表单字段未传递给表单处理程序:http://riccipsych.com/sendmail.php。我收到了包含所有表单标签的电子邮件,但是这些字段是空白的。

以下是每个页面的代码:

referrals.php

    <p><?php
        $ipi = getenv("REMOTE_ADDR");
        $httprefi = getenv ("HTTP_REFERER");
        $httpagenti = getenv ("HTTP_USER_AGENT");
    ?>


    <input type="hidden" name="ip" value="<?php echo $ipi ?>" />
    <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
    <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /></p>

          <form method="post" action="sendmail.php">

            <h3>Client Information:</h3>

            <label for="attn" class="label">Referral To:</label>
            <select id="attn" name="select">
              <option value="General">General</option>
                        <option value="Dr. Tammie Ricci, C.Psych.">Dr. Tammie Ricci, C.Psych.</option>
                        <option value="Dr. Paul Mendella, C.Psych.">Dr. Paul Mendella, C.Psych.</option>
                        <option value="Dr. Paul Roy, Psychiatrist">Dr. Paul Roy, Psychiatrist</option>
            </select>
            <br />

            <label for="cname" class="label">Client Name:</label>
                <input id="cname" type="text" name="textfield" maxlength="60">
            <br />

            <label for="caddress" class="label">Client Address:</label>
                <input id="caddress" type="text" name="textfield"  maxlength="60">
            <br />

            <label for="ccity" class="label">Client City:</label>
                <input id="ccity" type="text" name="textfield"  maxlength="50">
            <br />

            <label for="cprovince" class="label">Client Province:</label>
                <select id="cprovince" name="select">
                    <option value="NFLD">NFLD </option>
                    <option value="NS">NS </option>
                    <option value="PEI">PEI </option>
                    <option value="NB">NB </option>
                    <option value="PQ">PQ </option>
                    <option value="ON">ONT </option>
                    <option value="MAN">MAN </option>
                    <option value="SASK">SASK </option>
                    <option value="ALTA">ALTA </option>
                    <option value="BC">BC </option>
                    <option value="YT">YT </option>
                    <option value="NWT">NWT </option>
                    <option value="NVT">NVT </option>
                </select>
        <br />

        <label for="cpcode" class="label">Client Postal Code:</label>
                <input id="cpcode" type="text" name="textfield"  maxlength="7">
        <br />

        <label for="chphone" class="label">Client Home Phone:</label>
                <input id="chphone" type="text" name="textfield"  maxlength="15">
        <br />

        <label for="cwphone" class="label">Client Work Phone:</label>
                <input id="cwphone" type="text" name="textfield"  maxlength="15">
        <br />            

        <label for="ccphone" class="label">Client Cell Phone:</label>
                <input id="ccphone" type="text" name="textfield"  maxlength="15">
        <br />

        <label for="cdob" class="label">Client Date of Birth</label>
                <input id="cdob" type="text" name="textfield"  maxlength="20">
        <br />

        <label for="chmessage" class="label">Can we leave a message at the client's home?</label>
                <select id="chmessage" name="select">
                    <option value="Yes">Yes </option>
                    <option value="No">No </option>
                </select>
       <br />

       <label for="cwmessage" class="label">Can we leave a message at the client's workplace?</label>
                <select id="cwmessage" name="select">
                    <option value="Yes">Yes </option>
                    <option value="No">No </option>
                </select>
       <br />
       <br />

       <h3>Referral Information</h3>

       <label for="rname" class="label">Referral Name:</label>
                <input id="rname" type="text" name="textfield" maxlength="60">
            <br />

            <label for="raddress" class="label">Referral Address:</label>
                <input id="raddress" type="text" name="textfield"  maxlength="60">
            <br />

            <label for="rcity" class="label">Referral City:</label>
                <input id="rcity" type="text" name="textfield"  maxlength="50">
            <br />

            <label for="rprovince" class="label">Referral Province:</label>
                <select id="rprovince" name="select">
                    <option value="NFLD">NFLD </option>
                    <option value="NS">NS </option>
                    <option value="PEI">PEI </option>
                    <option value="NB">NB </option>
                    <option value="PQ">PQ </option>
                    <option value="ON">ONT </option>
                    <option value="MAN">MAN </option>
                    <option value="SASK">SASK </option>
                    <option value="ALTA">ALTA </option>
                    <option value="BC">BC </option>
                    <option value="YT">YT </option>
                    <option value="NWT">NWT </option>
                    <option value="NVT">NVT </option>
                </select>
        <br />

        <label for="rpcode" class="label">Referral Postal Code:</label>
                <input id="rpcode" type="text" name="textfield"  maxlength="7">
        <br />

        <label for="rwphone" class="label">Referral Work Phone:</label>
                <input id="rwphone" type="text" name="textfield"  maxlength="15">
        <br />

        <label for="remail" class="label">Referral E-Mail:</label>
                <input id="remail" type="text" name="textfield"  maxlength="80">
        <br />

        <label for="notes" class="label">Notes:</label>
                <textarea id="notes" style="width: 300px; height: 150px;" name="textarea"></textarea>
        <br />
        <br />

<p><input type="submit" value="Send Form" /></p>

sendmail.php

  

<?php
    if(!$remail == "" && (!strstr($remail,"@") || !strstr($remail,"."))) 
    {
    echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
    $badinput = "<h2>Feedback was NOT submitted</h2>\n";
    echo $badinput;
    }
    if(empty($rname) || empty($remail) || empty($cname )) {
    echo "<h2>Use Back - fill in all fields</h2>\n";
    }

    $todayis = date("l, F j, Y, g:i a") ;

    $attn = $attn ; 
    $subject = $attn; 

    $notes = stripcslashes($notes); 

    $message = " $todayis [EST] \n
    Referral To: $attn \n
    Client Name: $cname \n
    Client Address: $caddress \n
    Client City: $ccity \n
    Client Province: $cprovince \n
    Client Postal Code: $cpcode \n
    Client Home Phone: $chphone \n
    Client Work Phone: $cwphone \n
    Client Cell Phone: $ccphone \n
    Client Date of Birth: $cdob \n
    Leave Message at Client's Home: $chmessage \n
    Leave Message at Client's Workplace: $chmessage \n
    Referral Name: $rname \n
    Referral Address: $raddress \n
    Referral City: $rcity \n
    Referral Province: $rprovince \n
    Referral Postal Code: $rpcode \n
    Referral Work Phone: $rwphone \n
    Referral Email: $remail \n
    Notes: $notes \n 
    From: $rname ($remail)\n
    Additional Info : IP = $ip \n
    Browser Info: $httpagent \n
    Referral : $httpref \n
    ";

    $from = "From: $remail\r\n";


    mail("info@riccipsych.com", $subject, $message, $from);

?>

<h1>Thank You</h1>
<p>Thank you for submitting your referral. We will contact you shortly.</p>

它仍然无效。我将sendmail.php更改为sendeail.php并添加:

  

<?php

    $ip = $_POST['ip']; 
    $httpref = $_POST['httpref']; 
    $httpagent = $_POST['httpagent']; 
    $attn = $_POST['attn'];
    $cname = $_POST['cname'];
    $caddress = $_POST['caddress'];
    $ccity = $_POST['ccity'];
    $cprovince = $_POST['cprovince'];
    $cpcode = $_POST['cpcode'];
    $chphone = $_POST['chphone'];
    $cwphone = $_POST['cwphone'];
    $ccphone = $_POST['ccphone'];
    $cdob = $_POST['cdob'];
    $chmessage = $_POST['chmessage'];
    $cwmessage = $_POST['cwmessage'];
    $rname = $_POST['rname'];
    $raddress = $_POST['raddress'];
    $rcity = $_POST['rcity'];
    $rprovince = $_POST['rprovince'];
    $rpcode = $_POST['rpcode'];
    $rwphone = $_POST['rwphone'];
    $remail = $_POST['remail'];
    $notes = $_POST['notes'];

    if(!$remail == "" && (!strstr($remail,"@") || !strstr($remail,"."))) 
    {
    echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
    $badinput = "<h2>Feedback was NOT submitted</h2>\n";
    echo $badinput;
    }
    if(empty($rname) || empty($remail) || empty($cname )) {
    echo "<h2>Use Back - fill in all fields</h2>\n";
    }

    $todayis = date("l, F j, Y, g:i a") ;

    $attn = $attn ; 
    $subject = $attn; 

    $notes = stripcslashes($notes); 

    $message = " $todayis [EST] \n
    Referral To: $attn \n
    Client Name: $cname \n
    Client Address: $caddress \n
    Client City: $ccity \n
    Client Province: $cprovince \n
    Client Postal Code: $cpcode \n
    Client Home Phone: $chphone \n
    Client Work Phone: $cwphone \n
    Client Cell Phone: $ccphone \n
    Client Date of Birth: $cdob \n
    Leave Message at Client's Home: $chmessage \n
    Leave Message at Client's Workplace: $chmessage \n
    Referral Name: $rname \n
    Referral Address: $raddress \n
    Referral City: $rcity \n
    Referral Province: $rprovince \n
    Referral Postal Code: $rpcode \n
    Referral Work Phone: $rwphone \n
    Referral Email: $remail \n
    Notes: $notes \n 
    From: $rname ($remail)\n
    Additional Info : IP = $ip \n
    Browser Info: $httpagent \n
    Referral : $httpref \n
    ";

    $from = "From: $remail\r\n";


    mail("info@riccipsych.com", $subject, $message, $from);

?>

<h1>Thank You</h1>
<p>Thank you for submitting your referral. We will contact you shortly.</p>

1 个答案:

答案 0 :(得分:0)

您需要使用$_POST$_REQUEST在sendmail.php中定义变量:

$remail = $_REQUEST['remail'];

要查看您拥有的变量,您还可以在sendmail.php上使用以下代码

foreach($_REQUEST as $k => $v) 

echo "$k = $v\n";