PHP将变量传递到下一页不起作用
我想将一个变量传递到下一页,但似乎没有按预期工作。我在另一页上做了同样的事情,但现在不行了PHP将变量传递到下一页不起作用,php,html,Php,Html,我想将一个变量传递到下一页,但似乎没有按预期工作。我在另一页上做了同样的事情,但现在不行了 这是我用来传递变量的方法(email.php): 在excelimport.php中我有这样一个:$pidnew4=$\u POST['pidnew3'] 我在excelimport.php中遇到2个错误: Notice: Undefined index: pidnew3 in D:\home\site\wwwroot\devlopment\excelimport.php on line 77 其
这是我用来传递变量的方法(email.php):
在excelimport.php中我有这样一个:$pidnew4=$\u POST['pidnew3']代码>
我在excelimport.php中遇到2个错误:
Notice: Undefined index: pidnew3 in D:\home\site\wwwroot\devlopment\excelimport.php on line 77
其引用如下:$pidnew4=$\u POST['pidnew3']代码>
这是指:$recResult=mysql\u fetch\u数组($sql)代码>
我有一个php(email.php)页面,我想传递给另一个:
<?php
include_once 'includes/db_connect.php';
include_once 'includes/functions2.php';
include_once 'includes/config.php';
error_reporting(-1); ini_set( 'display_errors', 1 );
//Start av sessions
sec_session_start();
if (login_check($mysqli) == true) {
$logged = 'Inloggad';
} else {
$logged = 'utloggad';
}
$uploadedStatus = 0;
if ( isset($_POST["submit"]) ) {
if ( isset($_FILES["file"])) {
//if there was an error uploading the file
if ($_FILES["file"]["error"] > 0) {
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else {
if (file_exists($_FILES["file"]["name"])) {
unlink($_FILES["file"]["name"]);
}
$storagename = "discussdesk.xlsx";
move_uploaded_file($_FILES["file"]["tmp_name"], $storagename);
$uploadedStatus = 1;
}
} else {
echo "Ingen fil vald <br />";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Kandidater</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.709">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- jQuery library -->
<script src="js/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="main.css">
<link rel="shortcut icon" href="logo/wfmini.png">
<script type="text/javascript" language="javascript">
function checkedbox(element) {
var checkboxes = document.getElementsByTagName('input');
if (element.checked) {
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = true;
}
}
} else {
for (var i = 0; i < checkboxes.length; i++) {
console.log(i)
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = false;
}
}
}
}
</script>
<script src="js/tinymce/js/tinymce/tinymce.min.js"></script>
<script>tinymce.init({selector:'textarea'});</script>
</head>
<body class="dashboardadmin">
<ss="container-fluid" style="width:50%;">
<br>
<center><h3>Skicka email till kandidater</h3></center>
<br>
<p>Välj kandidater</p>
<form method="post" action="">
<?php
$pidnew2 = $_GET['pidnew'];
// Retrieve Email from Database
$getemail = mysql_query("SELECT * FROM Email_Users WHERE pid='".$pidnew2."'");
if (!$getemail) die('MySQL Error: ' . mysql_error());
echo '<table class="table table-bordered">';
echo "<thead>
<tr>
<th><input type='checkbox' onchange='checkedbox(this)' name='chk'/></th>
<th>Förnamn</th>
<th>Efternamn</th>
<th>Email</th>
</tr>
</thead>";
if (mysql_num_rows($getemail) == 0) {
echo "<tbody><tr><td colspan='3'>No Data Avaialble</td></tr></tbody>";
}
while ($row = mysql_fetch_assoc($getemail)) {
echo "<tbody><tr><td><input value='".$row['Email']."' type='checkbox' name='check[]'/></td>";
echo "<td >".$row['fornamn']."</td>";
echo "<td >".$row['efternamn']."</td>";
echo "<td >".$row['Email']."</td></tr></tbody>";
}
echo "</table>";
?>
</form>
</center>
<br>
</div>
<table width="600" style="margin:115px auto; background:#f8f8f8; border:1px solid #eee; padding:10px;">
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" enctype="multipart/form-data">
<tr><td colspan="2" style="font:bold 15px arial; text-align:center; padding:0 0 5px 0;">Ladda upp kandidater</td></tr>
<tr>
<td width="50%" style="font:bold 12px tahoma, arial, sans-serif; text-align:right; border-bottom:1px solid #eee; padding:5px 10px 5px 0px; border-right:1px solid #eee;">Välj fil</td>
<td width="50%" style="border-bottom:1px solid #eee; padding:5px;"><input type="file" name="file" id="file" /></td>
</tr>
<tr>
<td style="font:bold 12px tahoma, arial, sans-serif; text-align:right; padding:5px 10px 5px 0px; border-right:1px solid #eee;">Send</td>
<div class='alternativ'>
<td width="50%" style=" padding:5px;">
<form method='GET' action='excelimport.php'>
<input type='hidden' name='pidnew3' value='$pidnew2'>
<input type="submit" name="submit">
</form></td>
</div>
</tr>
</table>
<?php if($uploadedStatus==1){
header('Location: excelimport.php');
}?>
</form>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-38304687-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>
康迪达
函数复选框(元素){
var复选框=document.getElementsByTagName('input');
如果(元素已选中){
对于(变量i=0;i
Skicka在kandidater之前发送电子邮件
Välj kandidater
var _gaq=_gaq | |[];
_gaq.push([''设置帐户','UA-38304687-1']);
_gaq.push([''u trackPageview']);
(功能(){
var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;
ga.src=('https:'==document.location.protocol?'https://ssl' : 'http://www“)+”.google analytics.com/ga.js';
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);
})();
下面是另一个(excelimport.php):
您应该通过POST更改表单中的方法,因为您正试图通过“get”获取一个变量。或者如下所示,您可以使用“get”方法获取变量
$pidnew4=$\u GET['pidnew3'];
到
我刚刚意识到可能有什么问题,您没有在此处显示$pidnew2值
<form method='GET' action='excelimport.php'>
<input type='hidden' name='pidnew3' value='$pidnew2'>
<input type="submit" name="submit">
</form>
你应该把那个块换成
<form method='GET' action='excelimport.php'>
<input type='hidden' name='pidnew3' value='<?php echo $pidnew2; ?>'>
<input type="submit" name="submit">
</form>
这是我用来传递变量
和第二页$pidnew4=$\u POST['pidnew3']的方法代码>请用评论内容更新您的问题,并告诉我们问题是什么。现在毫无疑问。“不工作”是没有用的。PHP错误消息?控制台错误?@mplungjan谢谢,我添加了更多信息。@Fredrik$_GET['pidnew']来自哪里,它似乎包含了pidnew3应该是的值。如果它是空的,它解释了为什么你的'pidnew3'索引将是未定义的,因为值不会通过表单发送。我真的不知道我做错了什么。因为我在其他页面上使用了一些princible,没有更大的问题。我想在我的代码中有一些东西重新对页面进行了排序,然后丢失了pidnew
,这可能吗?谢谢你的重播,但这不管用。我真的不知道我做错了什么。因为我在其他页面上使用了一些princible,没有更大的问题。我认为我的代码中有某种东西会重新对页面进行排序,然后丢失pidnew
,这可能吗?
<form method='GET' action='excelimport.php'>
<input type='hidden' name='pidnew3' value='$pidnew2'>
<input type="submit" name="submit">
</form>
$pidnew4 = $_POST['pidnew3'];
$pidnew4 = $_GET['pidnew3'];
<form method='GET' action='excelimport.php'>
<input type='hidden' name='pidnew3' value='$pidnew2'>
<input type="submit" name="submit">
</form>
<form method='GET' action='excelimport.php'>
<input type='hidden' name='pidnew3' value='<?php echo $pidnew2; ?>'>
<input type="submit" name="submit">
</form>