2013-04-25 40 views
-3
<?php 

ini_set("log_errors", 1); 
ini_set("error_log", "errorlog.log"); 


$recid= $_POST['recid']; 
$username = $_POST['name']; 
$email = $_POST['email']; 
$ownername = $_POST['ownername']; 

include ("connection.php"); 


$result = $db->query("UPDATE users SET verified='y' WHERE recid='$recid'"); 

$filename = str_replace(" ","_", trim($username)); 
mkdir("Business_Pages/". $filename."/"); 



$jquery = "<script src='http://code.jquery.com/jquery-1.9.1.min.js'> </script>"; 
$jqueryui = "<script src='http://code.jquery.com/ui/1.10.2/jquery-ui.js'> </script>"; 
$jquerycss = "<link rel='stylesheet' href='http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css'>"; 
$postdata = "<script src='../../Scripts/postdata.js'> </script>"; 
$pagecss = "<link rel='stylesheet' href='../../CSS/businesspages.css'>"; 
$wclogo = "<img src='../../wc.png' id='wc'>"; 
$postinput = "<input type='text' id='post' placeholder='Post' name='post'>"; 
$postdate = "<input type='text' id='date' placeholder='Enter Date' name='date'>"; 
$accountinfo = "<table id='accountinfo'> <tr> <td> <img src='../../testresteraunt.png' id='testresteraunt'> </td> </tr> <tr>      <td> $username </td> </tr> <tr> <td> $ownername </td> </tr> </table>"; 
$links = "<table id='links'> <tr> <td> </td> <td> </td> </tr> </table> <div id='header'>"; 

$fp = fopen("Business_Pages/". $filename . "/" . $filename . ".html", "w"); 

fwrite($fp,"<?php session_start()"); 


fwrite($fp,"if(isset($_SESSION['id'])) { ?>"); 

fwrite($fp,"<!DOCTYPE html> <html> <head>"); 

fwrite($fp,"</head>"); 

fwrite($fp,"<body>"); 

fwrite($fp,"</body> </html>"); 

fwrite($fp,"<?php } ?>"); 

fclose($fp); 

$to = "$email"; 
$subject = "Account Creation"; 
$message = "Congratulations you have been accepted to Wolfeboro Connection"; 
$from = "[email protected]"; 
$headers = "From:" . $from; 


mail($to, $subject, $message, $headers) 

?> 

我只是在試圖顯示HTML,如果會話是有效的,但PHP是說,它的一個意想不到的if語句和
解析錯誤:語法錯誤,意想不到的T_ENCAPSED_AND_WHITESPACE,上線預計在T_STRING或T_VARIABLE或T_NUM_STRING /home/content/96/10688096/html/verify.php提前
感謝顯示頁面的HTML,如果存在會話

+1

爲什麼你使用'fp'和'fwrite' ..你想顯示在瀏覽器頁面或希望它被寫入到文件...? – 2013-04-25 04:50:13

+0

注意插值:根據腳本中的早期代碼,if(isset($ _ SESSION = ['id')){?>「'可能不會輸出您期望的內容。如果'$ _SESSION'是一個它應該是的數組,那麼輸出文件中的相關行會讀取'if(isset(array = ['id')){?>'。 – 2013-04-25 04:53:43

+0

正確的,我想它fwrite來一個文件,我登錄轉到該文件,但我希望它不會去的文件,如果你不登錄 – 2013-04-25 04:58:11

回答

1

這是錯誤的

if(isset($_SESSION=['id')) { 

你不需要等號(=)

試試這個

if(isset($_SESSION['id'])) { 
+2

您在聲明中錯過了一些東西..'如果(isset($ _ SESSION [ '身份證')){'應該是這樣'如果(isset($ _ SESSION [ '身份證'])) {'..失蹤']'.. – 2013-04-25 04:52:19

+0

@HirenPandya +1進行更正。謝謝:) – 2013-04-25 04:57:27

2

如果你想顯示在瀏覽器上的頁面,那麼你應該做以下,而不是寫的文件,然後顯示它。只需將以下代碼寫入要檢查會話的文件中即可。

<?php 
session_start(); 
if(isset($_SESSION['id'])) { 
?> 

<!DOCTYPE html> 
<html> 
<head> 
</head> 
<body></body> </html> 

<?php } ?> 

希望它有幫助。

好吧,我發現了錯誤..看看下面一行

fwrite($fp,"if(isset(".$_SESSION['id'].")) { ?>"); 

將這個在你的代碼,它應該正常工作。讓我知道,如果再出現問題...

嘿,這是我在我的機器上嘗試最新的代碼和它的工作...有它一看,讓我知道結果..

<?php 
ini_set("log_errors", 1); 
ini_set("error_log", "errorlog.log"); 

$fp = fopen("newtest.php", "w"); 
fwrite($fp,"<?php session_start();"); 
fwrite($fp,"if(isset(\$_SESSION['id'])) { ?>"); 
fwrite($fp,"<!DOCTYPE html> <html> <head>"); 
fwrite($fp,"</head>"); 
fwrite($fp,"<body>"); 
fwrite($fp,"</body> </html>"); 
fwrite($fp,"<?php } ?>"); 
fclose($fp); 
?> 

希望它能幫助。

+0

那是什麼正被寫入該文件作爲HTML和PHP即時得到一個錯誤的語法錯誤,意想不到的T_ENCAPSED_AND_WHITESPACE,期待T_STRING或T_VARIABLE或T_NUM_STRING – 2013-04-25 05:42:43

+0

嗯,我還沒有收到這個錯誤..你可能會失去了一些東西..請將您的完整代碼到的問題..可能有一些東西,是被錯過... – 2013-04-25 05:50:56

+0

@PhilPilon ..我已經更新了答案..請檢查一下...... – 2013-04-25 06:27:05