Php 单击提交时重定向到yahoo.com

Php 单击提交时重定向到yahoo.com,php,Php,我创建了一个from,其中有3个输入名称、电子邮件、电话号码,但当我通过我的雅虎电子邮件地址输入电子邮件字段时,电子邮件字段不是可选的,它会重定向到yahoo.com!!!我正在使用“GET”发送数据 $sql = "INSERT INTO $prefix"."buy_info (ip,email,name,phone,link,cost,expire,discode,product,buy_id,zarin_code,ok,date) VALUES ('" . $ip . "','" . $_

我创建了一个from,其中有3个输入名称、电子邮件、电话号码,但当我通过我的雅虎电子邮件地址输入电子邮件字段时,电子邮件字段不是可选的,它会重定向到yahoo.com!!!我正在使用“GET”发送数据

$sql = "INSERT INTO $prefix"."buy_info (ip,email,name,phone,link,cost,expire,discode,product,buy_id,zarin_code,ok,date) VALUES ('" . $ip . "','" . $_GET['email'] . "','" . $_GET['name'] . "','" . $_GET['phone'] . "','" . $_SESSION['url'] . "','" . $_SESSION['h_cost'] . "','" . $expire_time . "','" . $discode . "','" . $_SESSION['title'] . "','" . $buy_id . "','N','" . "1" . "','" . date("Y/m/d") . "')";
$act = mysql_query($sql) or die(mysql_error());

$_SESSION['buy_id'] = $buy_id;
$_SESSION['email'] = $_GET['email'];
$_SESSION['h_cost'] = $_GET['h_cost'];
和我的html表单:

    <form style="display: block" action="" id="pay_form" method="get">
<input type="text" name="discode" id="discode" class="discode_input" placeholder="کد تخفیف" />
<input type="button" name="discode_do" id="discode_do" class="discode_do" value="استفاده" /><img class="dd_w" src="img/w8.gif" alt="w8" />
<div class="total-cost">مبلغ قابل پرداخت : <i id="mqp" style="font-style: normal"><?php echo $_SESSION['h_cost'] ?></i> ت</div>
    <input name="name" placeholder="نام کامل" type="text" /><div class="cls"></div>
    <input name="email" id="email" placeholder="آدرس ایمیل*" type="email" /><div class="cls"></div>
    <input name="phone" style="    position: relative;top: 4px;" placeholder="شماره تماس" type="text" />
    <input type="submit" name="pay" class="pay" value="پرداخت">
</form>
使用重定向

header('Location: https://yahoo.com');
如果像这样成功

$sql = "INSERT INTO $prefix"."buy_info (ip,email,name,phone,link,cost,expire,discode,product,buy_id,zarin_code,ok,date) VALUES ('" . $ip . "','" . $_GET['email'] . "','" . $_GET['name'] . "','" . $_GET['phone'] . "','" . $_SESSION['url'] . "','" . $_SESSION['h_cost'] . "','" . $expire_time . "','" . $discode . "','" . $_SESSION['title'] . "','" . $buy_id . "','N','" . "1" . "','" . date("Y/m/d") . "')";
$act = mysql_query($sql) or die(mysql_error());

if($act){
    header('Location: https://yahoo.com');
}
这是我的全部代码:

<html>

<?php
session_start();

if (empty($_SESSION['h_cost'])) {$_SESSION['h_cost'] = $_SESSION['cost'];}

if (isset($_SESSION['cost']) and $_SESSION['cost'] != '') {

require("system/config.php");

$ip = GetRealIp();

if (isset($_GET['pay'])) {

$expire_time = time() + 259200;
$discode = '';
$now = time();
$buy_id = "$now";

for ($n=0;$n<20;$n++) {
    $buy_id .= rand(1,9);
}

if (intval($_SESSION['h_cost']) < 100) {
$sql = "INSERT INTO $prefix"."buy_info (ip,email,name,phone,link,cost,expire,discode,product,buy_id,zarin_code,ok,date) VALUES ('" . $ip . "','" . $_GET['email'] . "','" . $_GET['name'] . "','" . $_GET['phone'] . "','" . $_SESSION['url'] . "','" . $_SESSION['h_cost'] . "','" . $expire_time . "','" . $discode . "','" . $_SESSION['title'] . "','" . $buy_id . "','N','" . "1" . "','" . date("Y/m/d") . "')";
$act = mysql_query($sql) or die(mysql_error());

// Remote Connect

mysql_close();

define("re_adress","***");
define("re_username","***");
define("re_password","***");
define("re_db_name","***");

$prefix = "mby_";

$con=mysql_connect(re_adress,re_username,re_password);

mysql_query("SET NAMES 'utf8'", $con);
mysql_query("SET CHARACTER SET 'utf8'", $con);
mysql_query("SET character_set_connection = 'utf8'", $con);
mysql_select_db(re_db_name,$con) or die (mysql_error());

$sql = "INSERT INTO $prefix"."buy_info (ip,email,name,phone,link,cost,expire,discode,product,buy_id,zarin_code,ok,date) VALUES ('" . $ip . "','" . $_GET['email'] . "','" . $_GET['name'] . "','" . $_GET['phone'] . "','" . $_SESSION['url'] . "','" . $_SESSION['h_cost'] . "','" . $expire_time . "','" . $discode . "','" . $_SESSION['title'] . "','" . $buy_id . "','N','" . "1" . "','" . date("Y/m/d") . "')";
$act = mysql_query($sql) or die(mysql_error());

$_SESSION['buy_id'] = $buy_id;
$_SESSION['email'] = $_GET['email'];
$_SESSION['h_cost'] = $_GET['h_cost'];
Header('Location: /payment-result.php');
exit();
}

// Zarrin pall part

$MerchantID = '***'; //Required
$Amount = $_SESSION['h_cost']; //Amount will be based on Toman - Required
$Description = $_SESSION['title']; // Required
$Email = $_GET['email']; // Optional
$Mobile = $_GET['phone']; // Optional
$CallbackURL = $site_adress.'/payment-result.php'; // Required


$client = new SoapClient('https://www.zarinpal.com/pg/services/WebGate/wsdl', ['encoding' => 'UTF-8']);

$result = $client->PaymentRequest(
[
'MerchantID' => $MerchantID,
'Amount' => $Amount,
'Description' => $Description,
'Email' => $Email,
'Mobile' => $Mobile,
'CallbackURL' => $CallbackURL,
]
);

//Redirect to URL You can do it also by creating a form
if ($result->Status == 100) {
$sql = "INSERT INTO $prefix"."buy_info (ip,email,name,phone,link,cost,expire,discode,product,buy_id,ok,date) VALUES ('" . $ip . "','" . $_GET['email'] . "','" . $_GET['name'] . "','" . $_GET['phone'] . "','" . $_SESSION['url'] . "','" . $_SESSION['h_cost'] . "','" . $expire_time . "','" . $discode . "','" . $_SESSION['title'] . "','" . $buy_id . "','" . "0" . "','" . date("Y/m/d") . "')";
$act = mysql_query($sql) or die(mysql_error());

// Remote Connect

mysql_close();

define("re_adress","***");
define("re_username","***");
define("re_password","***");
define("re_db_name","***");

$prefix = "mby_";

$con=mysql_connect(re_adress,re_username,re_password);

mysql_query("SET NAMES 'utf8'", $con);
mysql_query("SET CHARACTER SET 'utf8'", $con);
mysql_query("SET character_set_connection = 'utf8'", $con);
mysql_select_db(re_db_name,$con) or die (mysql_error());

$sql = "INSERT INTO $prefix"."buy_info (ip,email,name,phone,link,cost,expire,discode,product,buy_id,ok,date) VALUES ('" . $ip . "','" . $_GET['email'] . "','" . $_GET['name'] . "','" . $_GET['phone'] . "','" . $_SESSION['url'] . "','" . $_SESSION['h_cost'] . "','" . $expire_time . "','" . $discode . "','" . $_SESSION['title'] . "','" . $buy_id . "','" . "0" . "','" . date("Y/m/d") . "')";
$act = mysql_query($sql) or die(mysql_error());

mysql_close();

$_SESSION['buy_id'] = $buy_id;
$_SESSION['email'] = $_GET['email'];
Header('Location: https://www.zarinpal.com/pg/StartPay/'.$result->Authority);
//برای استفاده از زرین گیت باید ادرس به صورت زیر تغییر کند:
//Header('Location: https://www.zarinpal.com/pg/StartPay/'.$result->Authority.'/ZarinGate');
} else {
echo'ERR: '.$result->Status;
}

}
else
{
$_SESSION['h_cost'] = $_SESSION['cost'];
$_SESSION['discode'] = NULL;
}
}
else
{
//header("location: /404.php");
}
?>

<head>
    <title>سبد خرید</title>
    <meta   http-equiv="content-type"   content="text/html;charset=utf-8"  />
    <meta   http-equiv="Content-Language"  content="Fa">

    <!--FavIcon-->
    <link rel="icon" type="image/png" href="img/favicon.png">

    <link rel="stylesheet" href="css/cart.css" />
    <link rel='stylesheet' href='css/font-style.css' >
    <link rel="stylesheet" href="css/font-awesome.min.css" >
    <link rel="stylesheet" href="css/bootstrap.min.css" >
    <link rel="stylesheet" href="css/style.css" >
</head>

<body>

<div class="header-area">
            <div class="container">
                    <div class="row">
                            <div class="col-md-8">
                                    <div class="user-menu">
                                            <ul>
                                                    <li><a href="#"><i class="fa fa-user"></i>ورود</a></li>
                                                    <li><a href="#"><i class="fa fa-pencil-square-o"></i> ثبت نام</a></li>
                                                    <li><a href="#"><i class="fa fa-phone"></i>ارتباط با ما</a></li>
                                                    <li><a href="#"><i class="fa fa-briefcase"></i>همکاری</a></li>
                                            </ul>
                                    </div>
                            </div>
                            <div style="width: 300px;float: right;text-align: right;height: 38px;line-height: 38px;" class="col-md-9"><?php echo $psubtitle; ?>&nbsp;<i style="font-size: 10px;" class="fa fa-star"></i></div>
                    </div>
            </div>
</div> <!-- End header area -->

<section class="adjuster">
<a href="http://mobyar.com"><img src="img/logo.png" style="border-bottom: #999999 dashed 1px;position: absolute;top: 15px;left:10px;width: 200px;height: 95px;" alt="" /></a>
<b style="border-bottom: #999999 dashed 1px;font-weight: normal;position: absolute;width: 580px; height: 100px;line-height: 130px;text-align: center;font-size: 25px;top: 10px;" >فاکتور فروش خدمات موب یار</b>
<table>
    <td style="background: #5a88ca;color: #fff;font-weight: normal;" width="600">نام محصول</td><td style="background: #5a88ca;color: #fff;font-weight: normal;" width="200">قیمت</td><tr></tr>
    <td class="p_title"><?php echo $_SESSION['title'] ?></td><td><?php echo $_SESSION['cost'] ?> ت</td><tr></tr>
</table>
<form style="display: block" action="" id="pay_form" method="get">
<input type="text" name="discode" id="discode" class="discode_input" placeholder="کد تخفیف" />
<input type="button" name="discode_do" id="discode_do" class="discode_do" value="استفاده" /><img class="dd_w" src="img/w8.gif" alt="w8" />
<div class="total-cost">مبلغ قابل پرداخت : <i id="mqp" style="font-style: normal"><?php echo $_SESSION['h_cost'] ?></i> ت</div>
    <input name="name" placeholder="نام کامل" type="text" /><div class="cls"></div>
    <input name="email" id="email" placeholder="آدرس ایمیل*" type="email" /><div class="cls"></div>
    <input name="phone" style="    position: relative;top: 4px;" placeholder="شماره تماس" type="text" />
    <input type="submit" name="pay" class="pay" value="پرداخت">
</form>
<div class="discode_result">
    <div class="dr_c"></div>
    <b>کد تخفیف اعمال شد !</b>
    <br>
    <br>
    <i>مبلغ پرداختی شما شامل x % تخفیف شده است</i>
</div>
<div class="cls"></div>
</section>

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/cart.js"></script>

</body>

</html>

我刚刚把email字段名改为user\u email,它现在可以工作了,没有问题了,email字段名就是问题所在!!!:D

张贴olso您的表格和输入我不明白!上面的代码在数据库中插入值。这与重定向无关。我们必须查看您的表单请澄清您的问题如果您正在编写新代码,请不要使用mysql_*函数。它们已经过时了,在PHP5.5中被弃用,PHP5.5太旧了,甚至不再接收安全更新,在PHP7中被完全删除。使用或与准备好的语句和参数绑定一起使用。有关详细信息,请参阅。