你怎么摆脱这两个恼人的错误plzzzz [英] How do you get rid of these two annoying errors plzzzz

查看:97
本文介绍了你怎么摆脱这两个恼人的错误plzzzz的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编辑页面,编辑后啊应该能够更新信息,换句话说我正在做编辑页面和更新,但我可以让编辑页面编辑或更新信息。更新页面中的




,我收到这些错误并一直试图解决它。



这是错误号1.

未定义变量:userName  C:\ wamp64 \过网络中的内容 30  







这是错误号码。 2

:未定义的变量:密码 C:\ wamp64 \ www。\\\\\\\\\\\\\\\\ php \update.php在线 30  







,这就是我到目前为止所做的,我真的需要从中移动一个,但我必须得到工作而且我被卡住了,有人可以帮助我在这里。非常感谢



我尝试过:



这是更新码。



 <   pre  >  <? php 

session_start() ;
$ _SESSION [' user'];
// $ title = $ _ POST ['title'];
$ firstname = $ _ POST [' firstname'];
$ lastname = $ _ POST [' lastname'];
// $ address = $ _ POST ['address'];
< span class =code-comment> // $ txtemail = $ _ POST ['txtemail'];
// $ gender = $ _ POST ['gender'];
/ /


// 创建与数据库的连接
$ db_host = ' localhost'< /跨度>;
$ db_username = ' root';
$ db_password = ;


// 检查连接
$ con = mysqli_connect($ db_host,$ db_username,$ db_password) die(mysqli_connect_error());

// 选择数据库
mysqli_select_db($ con, ' food' die(mysqli_error) ($ CON));


// $ userName = $ _ SESSION ['user'];
// $ password = $ _ SESSION ['user'];

$ sql = SELECT * FROM member WHERE userName ='$ userName'AND pword = md5( '$口令');
$ result = mysqli_query($ con,$ sql) die( 错误: .mysqli_error());

// 从数据库收集信息
if($ result )
{
$ rowcount = mysqli_num_rows($ result);

if($ rowcount == 1)
{

// 使用编辑表单中的信息更新数据库
$ update = 更新成员SET firstname ='$ firstname'WHERERE userName ='。$ _ SESSION [' user']。 ';
$ update = UPDATE成员SET lastname ='$ lastname'WHERE userName =' 。$ _ SESSION [' user']。 ';

// mysqli_query($ con,$ update)或die(mysqli_error($ con)) );

if(mysqli_query($ con,$ update))
{

echo < script type = \text / javascript \>
alert( '配置文件已成功更新。');
window.location = \profile.php \;
< / script>
;

mysqli_close($ con);
header( location:edit.php);

}
else
{
echo < scrip type = \text / javascript \>
alert('密码错误');
window.locaton = \edit.php \;
< / script>
;
}
}

}




? >

解决方案

_SESSION [' 用户];
//


title =


_POST [ '标题'];

I am trying to do an edit page and after editing ah should be able to update the information in other words am doing both an edit page and update but i can get the edit page to either edit or update the information.


in the update page, I am get these errors and have been banging my head trying to solve it.

this is the error no 1.

Undefined variable: userName in C:\wamp64\www\luana_itec244\php\update.php on line 30




this is error no. 2

: Undefined variable: password in C:\wamp64\www\luana_itec244\php\update.php on line 30




and here is what i have so far, I really need to move one from this but I have to get the working and I am stuck, can someone please help me out here. much thanks

What I have tried:

this is the update codes.

<pre><?php
		
			session_start();
			$_SESSION['user'];
			//$title=$_POST['title'];
			$firstname=$_POST['firstname'];
			$lastname=$_POST['lastname'];
			//$address=$_POST['address'];
			//$txtemail=$_POST['txtemail'];
			//$gender=$_POST['gender'];
			//
			
			
			//create connection to database
			$db_host='localhost';
			$db_username='root';
			$db_password="";
			
			
				//check connection
				$con = mysqli_connect($db_host, $db_username, $db_password) or die(mysqli_connect_error());
			
				//select the database
				mysqli_select_db($con, 'food') or die(mysqli_error($con));
				
				  	
					//$userName=$_SESSION['user'];
					//$password=$_SESSION['user'];
				 
					$sql="SELECT * FROM member WHERE userName='$userName' AND pword=md5('$password')";
					$result=mysqli_query($con, $sql) or die ("Error:" .mysqli_error());
					
					//collect info from database
					if($result)
					{
						$rowcount=mysqli_num_rows($result);
						
						if($rowcount==1)
						{
							
							//update database with information from the edit form
							$update="UPDATE member SET firstname='$firstname' WHERE userName='".$_SESSION['user']."'";
							$update="UPDATE member SET lastname='$lastname' WHERE userName='".$_SESSION['user']."'";
							
							//mysqli_query($con, $update) or die(mysqli_error($con));
							
							if(mysqli_query($con, $update))
							{                               
						
								echo "<script type=\"text/javascript\">
									alert('Profile successfully updated.');
									window.location=\"profile.php\";
									</script>";
									
								mysqli_close($con);
								header("location:edit.php");
								
							}
							else
							{
								echo "<scrip type=\"text/javascript\">
										  alert('Incorrect password');
										  window.locaton=\"edit.php\";
									  </script>";
							}
						}	
						
					}
			
		
		

?>

解决方案

_SESSION['user']; //


title=


_POST['title'];


这篇关于你怎么摆脱这两个恼人的错误plzzzz的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆