【发布时间】:2013-03-01 17:02:26
【问题描述】:
概述: 我正在创建一个用于学习目的的虚拟网站,因此它的功能主义者是基本且安全的,不在议程 atm 上。
问题: 当我登录系统并单击编辑帐户按钮时,我收到此错误:
解析错误:语法错误,第 104 行 C:\xampp\htdocs\eshop\userEditAccount.php 中的文件意外结束
userEditAccount.php 文件:
<?php
session_start();
require_once('userEditAccount.php');
include('connect_mysql.php');
if(isset($_POST['Editsubmited'])){
$userid = $_SESSION['user_id'];
$Newusername = $_POST['username'];
$Newpassword = $_POST['password'];
$Newfirstname = $_POST['first_name'];
$Newlastname = $_POST['last_name'];
$Newemail = $_POST['email'];
$sql = "UPDATE users SET username='$Newusername', password='$Newpassword',
first_name='$Newfirstname', last_name='$Newlastname WHERE user_id='$userid'";
$result = mysql_query($sql) or die("Query failed : " . mysql_error());
if(!$result){
exit("Error Ocured whilsd updating $ud_id record");
}
echo "Record $ud_id has been sucesfully updated";
mysql_close($con);
?>
<html>
<head>
<title>Edit Account</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper">
<header><h1>E-Shop</h1></header>
<article>
<h1>Welcome</h1>
<h1>Edit Account</h1>
<div id="login">
<ul id="login">
<form method="post" name="editAccount" action="userEditAccount.php" >
<fieldset>
<legend>Fill in the form</legend>
<label>Select Username : <input type="text" name="username" /></label>
<label>Password : <input type="password" name="password" /></label>
<label>Enter First Name : <input type="text" name="first_name" /></label>
<label>Enter Last Name : <input type="text" name="last_name" /></label>
<label>Enter E-mail Address: <input type="text" name="email" /></label>
</fieldset>
<br />
<input name="Editsubmited" type="submit" submit="submit" value="Edit Account" class="button">
</form>
<?
echo $newrecord;
?>
</div>
<form action="userhome.php" method="post">
<div id="login">
<ul id="login">
<li>
<input type="submit" value="back" onclick="index.php" class="button">
</li>
</ul>
</div>
</article>
<aside>
</aside>
<div id="footer">This is my site i Made coppyrights 2013 Tomazi</div>
</div>
</body>
</html>
查看代码一切看起来都是正确的,错误没有意义意外的文件结尾............
当我在一个单独的文件中使用 php 代码并将该文件与 html 文件链接时,我在 php 所在的文件中得到相同的错误,因此我猜它与 php 有关......
任何建议Overflowers:....?
【问题讨论】:
-
天啊,我正在学习的人,我正在尝试在增强代码之前建立基本功能,这个网站永远不会上线。我非常了解安全问题和 SQL 注入问题。
-
如果我发布一个问题来获得帮助并学习一些东西,而所有这些“聪明的人”寻找任何不喜欢某事的理由,这很难学习。就像每个人从一开始就让事情变得完美!!!!
-
好吧,我不同意@MikeB,我是一名 C++ 程序员,从代码完全增强和发布正版之前的经验来看......代码在开发,在我看来,最大的错误是从一开始就尝试开发 PERFECT 软件,这是当项目失败、资金耗尽并且永远无法完成时,这就是程序员做原型和测试版的原因
-
希望@MikeB 会让你开心 $newPassword = stripslashes(mysql_real_escape_string($_POST["password"]));