-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 = "info@wolfeboroconnection.com";
$headers = "From:" . $from;


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

?>

我试图仅在会话有效时显示 html,但 php 说它是意外的 if 语句和
解析错误:语法错误,意外的 T_ENCAPSED_AND_WHITESPACE,期望/home/content/96/10688096/html/中的 T_STRING 或 T_VARIABLE 或 T_NUM_STRING verify.php在第37
行提前致谢

4

2 回答 2

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);
?>

希望能帮助到你。

于 2013-04-25T04:59:10.543 回答
1

这是错误的

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

你有不想要的 = 符号

尝试这个

if( isset($_SESSION['id'])) { 
于 2013-04-25T04:49:02.940 回答