Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将php字段添加到电子邮件中_Javascript_Php_Jquery_Html_Forms - Fatal编程技术网

Javascript 将php字段添加到电子邮件中

Javascript 将php字段添加到电子邮件中,javascript,php,jquery,html,forms,Javascript,Php,Jquery,Html,Forms,所以我有一个FancyForm预先制作的表单,只有会话帖子名、电子邮件和消息。如果我添加了更多字段供用户填写,如何从表单中获取他在发送给我的电子邮件中键入的内容?下面是我要说的: <form id="contact-form" name="contact-form" method="post" action="submit.php"> <table width="100%" border="0" cellspacing="

所以我有一个FancyForm预先制作的表单,只有会话帖子名、电子邮件和消息。如果我添加了更多字段供用户填写,如何从表单中获取他在发送给我的电子邮件中键入的内容?下面是我要说的:

<form id="contact-form" name="contact-form" method="post" action="submit.php">
                            <table width="100%" border="0" cellspacing="0" cellpadding="5">
                                <tr>
                                    <td width="15%"><label for="name">Name</label></td>
                                    <td width="70%"><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="<?=$_SESSION['post']['name']?>" /></td>
                                    <td width="15%" id="errOffset">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td><label for="email">Email</label></td>
                                    <td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td>
                                    <td>&nbsp;</td>
                                </tr>
                                <tr>
                                    <td width="15%"><label for="length">Telephone</label></td>
                                    <td width="70%"><input type="text" class="validate[required,custom[onlyNumber]]" name="telephone" id="telephone" value="<?=$_SESSION['post']['telephone']?>" /></td>
                                    <td width="15%" id="errOffset">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td><label for="subject">Subject</label></td>
                                    <td><select name="subject" id="subject">
                                        <option value="" selected="selected"> - Choose -</option>
                                        <option value="Residential Job">Residential Job</option>
                                        <option value="Commercial Job">Commercial Job</option>
                                        <option value="Repair">Repair/Patch</option>
                                        <option value="Complaint">Complaint</option>
                                        <option value="Question">Question</option>
                                    </select></td>
                                    <td>&nbsp;</td>
                                </tr>
                                <tr>
                                    <td valign="top"><label for="message">Message</label></td>
                                    <td><textarea name="message" id="message" class="validate[required]" cols="35" rows="5"><?=$_SESSION['post']['message']?></textarea></td>
                                    <td valign="top">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td><label for="captcha"><?=$_SESSION['n1']?> + <?=$_SESSION['n2']?> =</label></td>
                                    <td><input type="text" class="validate[required,custom[onlyNumber]]" name="captcha" id="captcha" /></td>
                                    <td valign="top">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td valign="top">&nbsp;</td>
                                    <td colspan="2"><input type="submit" name="button" id="button" value="Submit" />                              
                                    <?=$str?>          <img id="loading" src="img/ajax-load.gif" width="16" height="16" alt="loading" /></td>
                                </tr>
                            </table>
                        </form>
预先制作的表单已经有名称和电子邮件地址字段,因此它们100%工作。我添加了我自己的“电话”会话帖子,但当我完成表格并通过电子邮件发送给自己时,只有姓名/电子邮件字段发送。我错过了什么

网站:

预制表格:

JSFiddle:

JSFiddle:

求你了,我想把这个整理一下

谢谢,科里

这是我在contact.php页面上在html之前调用的php:

<?php

session_name("fancyform");
session_start();


$_SESSION['n1'] = rand(1,20);
$_SESSION['n2'] = rand(1,20);
$_SESSION['expect'] = $_SESSION['n1']+$_SESSION['n2'];


$str='';
if($_SESSION['errStr'])
{
    $str='<div class="error">'.$_SESSION['errStr'].'</div>';
    unset($_SESSION['errStr']);
}

$success='';
if($_SESSION['sent'])
{
    $success='<h1>Success! We will be in contact!</h1>';

    $css='<style type="text/css">#contact-form{display:none;}</style>';

    unset($_SESSION['sent']);
}
?>

只需将新的会话后ID添加到submit.php表单中,我就能够解决这个问题。其实很简单

这是一个php问题。显示您的php代码。我在html标记之前添加了我调用的代码。PHP/JS的其余部分在上面的JSFiddles中。希望这能有所帮助。如果您需要更多,请明确告诉我我能为您提供什么,我会立即提供。只需将新的会话后ID添加到submit.php表单中,我就能够解决这个问题。其实很简单。