Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/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
Php 试图在两个html页面上携带值_Php_Html - Fatal编程技术网

Php 试图在两个html页面上携带值

Php 试图在两个html页面上携带值,php,html,Php,Html,我有一个带有表格的页面,可以通过电子邮件发送有关汽车配件的信息。例如,沃尔沃将有排气、发动机、内饰,沃克斯豪尔将有一些相同的领域和一些不同的领域等。 我进入沃尔沃部分,点击排气部门,它会把我带到一张我填写的表格,并通过电子邮件发送给沃尔沃。但是,我试图将第一页的值传递到零件部分:例如,如果我单击排气,它将传递到用户可以填写联系信息的表单,有问题的零件将从我刚才单击的按钮中填写 这是我的代码(第一个html页面): 当然,我有正确发送电子邮件所需的所有其他代码,我只是不想发布这些代码来迷惑任何人,

我有一个带有表格的页面,可以通过电子邮件发送有关汽车配件的信息。例如,沃尔沃将有排气、发动机、内饰,沃克斯豪尔将有一些相同的领域和一些不同的领域等。 我进入沃尔沃部分,点击排气部门,它会把我带到一张我填写的表格,并通过电子邮件发送给沃尔沃。但是,我试图将第一页的值传递到零件部分:例如,如果我单击排气,它将传递到用户可以填写联系信息的表单,有问题的零件将从我刚才单击的按钮中填写

这是我的代码(第一个html页面):


当然,我有正确发送电子邮件所需的所有其他代码,我只是不想发布这些代码来迷惑任何人,让他们知道我具体遇到了什么问题。

如果您在第一个HTML中有基于单击的选择,那么最好使用带有
$\u GET
的超链接,如果您认为通过地址栏传输数据是安全的。然后在第二个HTML页面中,您只需在表单的隐藏输入中填写传递的值。下面是参考代码

//This is 1st PHP where "sp" after "?" is short of Selected Part. You MUST use the value that will be stored in the DB or will be the Primary Key.
<a href="your_second_html_volvo.php?sp=Exhaust">Exhaust</a>

//2nd PHP - For instance selecting part of Volvo
<?php
    $selected_part = $_GET['sp'];
?>

<form action="your_action_script.php" method="POST">
    //Whatever details you want to collect
    <input type="text" name="customer_name" required>
    <input type="email" name="customer_email" required>

    //This is the Selected Part from the previous page
    <input type="hidden" name="selected_part" value=<?php echo "'" . $selected_part . "'" ?>>
</form>
//这是第一个PHP,其中“?”后面的“sp”缺少所选部分。必须使用将存储在DB中的值或主键。
//第二个PHP-例如选择沃尔沃的一部分
//不管你想收集什么细节
//这是上一页中选定的零件

如果必须使用多个页面,则使用会话听起来像是一种解决方案。请将表单移到表外。制作提交按钮复选框,最后只有一个提交按钮。下面是一个很好的例子,说明你应该更改什么。我认为如果你做了这个小更改,你将没有一个成功的机会problem@PeterDarmis我在表格中只有一个用于组织页面布局的按钮,在最后只有一个提交按钮?我会尝试建议的网页建议虽然!非常感谢。Mplungjan我已经有了一个公司名称的价值结转,它运行良好(如果我选择沃尔沃,它会结转并通过电子邮件发送主题行作为公司名称)。我可以尝试使用sessions,看看goesI已经到了什么程度,它会返回我可能做错了什么的想法?现在还剩下什么?在动作脚本中调用它?我已经到了发送电子邮件的阶段,但是在我选择的部分,我得到了行,而我假设我的值(6)应该被执行,我的开关应该读取值6并打印。它是通过脚本而不是通过数字6?虽然使用前面的代码是可以的,但您也可以尝试编辑的代码。投票否决必须包括推理,以帮助每个人提高。
switch($_POST['parts']){
    case 6:
    $email_message  = "wide exhaust";
    break;
    case 7:
    $email_message  = "dual exhaust";
    break;
}

$first_name      = $_POST['first_name']; // required
$last_name       = $_POST['last_name']; // required
$email_from      = $_POST['email']; // required
$maintelephone   = $_POST['maintelephone'];
$mobiletelephone = $_POST['mobiletelephone']; // not required
$address         = $_POST['address'];
$postcode        = $_POST['postcode'];
$dob             = $_POST['dob'];
$contact         = $_POST['contact'];

$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Main Number: ".clean_string($maintelephone)."\n";
$email_message .= "Mobile Number: ".clean_string($mobiletelephone)."\n";
$email_message .= "Address: ".clean_string($address)."\n";
$email_message .= "Postcode: ".clean_string($postcode)."\n";
$email_message .= "Date of Birth: ".clean_string($dob)."\n";
$email_message .= "Parts: ".clean_string($parts)."\n";
$email_message .= "Contact: ".clean_string($contact)."\n";
//This is 1st PHP where "sp" after "?" is short of Selected Part. You MUST use the value that will be stored in the DB or will be the Primary Key.
<a href="your_second_html_volvo.php?sp=Exhaust">Exhaust</a>

//2nd PHP - For instance selecting part of Volvo
<?php
    $selected_part = $_GET['sp'];
?>

<form action="your_action_script.php" method="POST">
    //Whatever details you want to collect
    <input type="text" name="customer_name" required>
    <input type="email" name="customer_email" required>

    //This is the Selected Part from the previous page
    <input type="hidden" name="selected_part" value=<?php echo "'" . $selected_part . "'" ?>>
</form>