課程
/后端開發
/PHP
/手把手教你實現電商網站后臺開發
為什么我javascript那個彈窗調用不了,直接把代碼輸出出來了,單獨運行沒有問題
2016-08-25
源自:手把手教你實現電商網站后臺開發 2-5
正在回答
看一下 html 源代碼,alert() 里面沒有加引號,JS 會把內容當作一個變量。
繁華如夢傾城殤 提問者
調用函數的代碼:
<?php
require_once '../include.php';
$username=$_POST['username'];
$password=md5($_POST['password']);
$verify=$_POST['verify'];
$verify1=$_SESSION['verify'];
$autoLogin=$_POST['autologin'];
if($verify==$verify1){
? ? $sql="select * from imooc_admin where username='{$username}' and password='{$password}'";
? ? $row=checkAdmin($sql);
? ? if($row){
? ? ? ? if($autoLogin){
? ? ? ? ? ? setcookie("adminId",$row['id'],time()+7*24*3600);
? ? ? ? ? ? setcookie("adminName",$row['name'],time()+7*24*3600);
? ? ? ? }
? ? ? ? $_SESSION['adminName']=$row['username'];
? ? ? ? header("location:index.php");
? ? }
? ? else{
? ? ? ? alertM("登錄失敗,重新登錄","login.php");
}
else{
? ? alertM("驗證碼錯誤,重新登錄","login.php");
? ??
函數的代碼:
function alertM($mes,$url){
? ? echo "<script language='javascript'>alert($mes);</script>";
? ? echo "<script>window.location=$url;</script>";
?>
包含地址的代碼:
<?php?
header("content-type:text/html;charset=utf-8");
date_default_timezone_set("PRC");
session_start();
define("ROOT",dirname(__FILE__));
set_include_path(".".PATH_SEPARATOR.ROOT."./lib".PATH_SEPARATOR.ROOT."./core".PATH_SEPARATOR.ROOT."./configs".PATH_SEPARATOR.get_include_path());
require_once 'image.php';
require_once 'string.php';
require_once "configs.php";
require_once 'mysql.php';
require_once 'admin.inc.php';
require_once 'common.php';
把你的js代碼貼出來,我看一下
舉報
手把手教你用PHP搭建電子商務平臺,由淺入深教你搭建電商系統
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-08-28
看一下 html 源代碼,alert() 里面沒有加引號,JS 會把內容當作一個變量。
2016-08-26
調用函數的代碼:
<?php
require_once '../include.php';
$username=$_POST['username'];
$password=md5($_POST['password']);
$verify=$_POST['verify'];
$verify1=$_SESSION['verify'];
$autoLogin=$_POST['autologin'];
if($verify==$verify1){
? ? $sql="select * from imooc_admin where username='{$username}' and password='{$password}'";
? ? $row=checkAdmin($sql);
? ? if($row){
? ? ? ? if($autoLogin){
? ? ? ? ? ? setcookie("adminId",$row['id'],time()+7*24*3600);
? ? ? ? ? ? setcookie("adminName",$row['name'],time()+7*24*3600);
? ? ? ? }
? ? ? ? $_SESSION['adminName']=$row['username'];
? ? ? ? header("location:index.php");
? ? }
? ? else{
? ? ? ? alertM("登錄失敗,重新登錄","login.php");
? ? }
}
else{
? ? alertM("驗證碼錯誤,重新登錄","login.php");
? ??
}
函數的代碼:
<?php
function alertM($mes,$url){
? ? echo "<script language='javascript'>alert($mes);</script>";
? ? echo "<script>window.location=$url;</script>";
}
?>
包含地址的代碼:
<?php?
header("content-type:text/html;charset=utf-8");
date_default_timezone_set("PRC");
session_start();
define("ROOT",dirname(__FILE__));
set_include_path(".".PATH_SEPARATOR.ROOT."./lib".PATH_SEPARATOR.ROOT."./core".PATH_SEPARATOR.ROOT."./configs".PATH_SEPARATOR.get_include_path());
require_once 'image.php';
require_once 'string.php';
require_once "configs.php";
require_once 'mysql.php';
require_once 'admin.inc.php';
require_once 'common.php';
2016-08-26
把你的js代碼貼出來,我看一下