Template Script strangely not working.
05-08-2008, 03:07 PM
|
Template Script strangely not working.
|
Posts: 1,572
Name: Stefan
Location: London, UK
|
This script generates a html page to download depending on what the user fills in in a form.
Don't be put off by the amount of code i'm posting, I just want to post all of it just in case.
where $page = 'nrmlpg', it works
but where $page = 'specs', it doesn't
PHP Code:
<?php
$html = ''; $act = $_REQUEST['act']; $edit = $_REQUEST['edit']; $manage = $_REQUEST['manage'];
// removed for security reasons mysql_connect("", "", "") or die(mysql_error()); mysql_select_db("") or die(mysql_error());
//removed for security reasons if(isset($_COOKIE[''])) { $username = $_COOKIE['']; $pass = $_COOKIE['']; $check = mysql_query("SELECT * FROM table WHERE column = '$username'")or die(mysql_error()); } else{ header("Location: login.php"); } while($info = mysql_fetch_array( $check )){ //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']){ header("Location: login.php"); } else { $site = $_POST['site']; $page = $_POST['page'];
// this part works if ($username == 'eurocarmarket.co.uk' || $page == 'nrmlpg') { $content = $_POST['content']; $content = nl2br($content); // look below for the contents of this file include ('eurocarmarket.php'); $title = $_POST['pgtitle']; $heading = $_POST['heading']; $ecm2 = preg_replace ('/\[title\](.*?)\[\/title\]/is', '</p><h1>$1</h1><p>', $ecm2); $ecm2 = preg_replace ('/\[b\](.*?)\[\/b\]/is', '<strong>$1</strong>', $ecm2); $ecm2 = preg_replace ('/\[i\](.*?)\[\/i\]/is', '<em>$1</em>', $ecm2); $ecm2 = preg_replace ('/\[u\](.*?)\[\/u\]/is', '<u>$1</u>', $ecm2); $ecm2 = preg_replace ('/\[img\](.*?)\[\/img\]/is', '<img src="$1" alt="Image" />', $ecm2); $ecm2 = preg_replace ('/\[url=(.*?)\](.*?)\[\/url\]/i', '<a href="$1">$2</a>', $ecm2); $ecm2 = htmlentities($ecm2);
$form = $ecm2;
$html .= '<form action="download.php" method="post"><textarea name="textarea" cols="80" rows="20">'.$form.' </textarea><input type="hidden" name="filename" value="'.$title.'"> <br><input type="submit" value="Download"></form>'; } // this part doesn't work elseif ($username == 'eurocarmarket.co.uk' || $page == 'specs') { $specs = $_POST['specs']; $specs = nl2br($specs); include ('eurocarmarket.php'); $carname = $_POST['pgtitle']; $image1 = $_POST['image1']; $image2 = $_POST['image2']; $image3 = $_POST['image3']; $image4 = $_POST['image4']; $image5 = $_POST['image5']; $image6 = $_POST['image6'];
$ecm4 = preg_replace ('/\[title\](.*?)\[\/title\]/is', '</p><h1>$1</h1><p>', $ecm4); $ecm4 = preg_replace ('/\[b\](.*?)\[\/b\]/is', '<strong>$1</strong>', $ecm4); $ecm4 = preg_replace ('/\[i\](.*?)\[\/i\]/is', '<em>$1</em>', $ecm4); $ecm4 = preg_replace ('/\[u\](.*?)\[\/u\]/is', '<u>$1</u>', $ecm4); $ecm4 = preg_replace ('/\[img\](.*?)\[\/img\]/is', '<img src="$1" alt="Image" />', $ecm4); $ecm4 = preg_replace ('/\[url=(.*?)\](.*?)\[\/url\]/i', '<a href="$1">$2</a>', $ecm4); $ecm4 = htmlentities($ecm4);
$form = $ecm4; $html .= '<form action="download.php" method="post"><textarea name="textarea" cols="80" rows="20">'.$form.' </textarea><input type="hidden" name="filename" value="'.$title.'"> <br><input type="submit" value="Download"></form>'; } else { $html .= 'No sites available'; }
} }
?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>SGilligan :: Editor</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="../css/style.css">
</head>
<body><div id="main">
<div class="logo"> </div>
<?php echo $iNav ?>
<div class="content2"> <div class="box3"> <div class="title style1" style="margin-bottom:30px">Editor - BETA</div> <div class="iBox"> <?=$html;?> </div>
</div></div>
</div> <?php echo $footer ?>
</body> </html>
eurocarmarket.php contains something LIKE this:
PHP Code:
<?php
$ecm2 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>'.$title.'</title> <link rel="stylesheet" type="text/css" href="http://www.sgilligan.co.uk/eurocarmarket/css/style.css" /> </head>
<body> <div id="container"> <div id="header"></div>
<div id="nav"> <ul> <li><a href="http://www.sgilligan.co.uk/eurocarmarket/index.html">Home</a></li> <li><a href="http://www.sgilligan.co.uk/eurocarmarket/stocklist">Stock List</a></li> <li><a href="http://www.sgilligan.co.uk/eurocarmarket/budget">Cars Under £2000</a></li> <li><a href="http://www.sgilligan.co.uk/eurocarmarket/about">Info</a></li> <li><a href="http://www.sgilligan.co.uk/eurocarmarket/finance">Finance</a></li> </ul> </div>
<div id="main"> <h1>'.$heading.'</h1> <p>'.$content.'</p>
<div class="space"></div> </div>
<div id="footer">Design by <a href="http://www.sgilligan.co.uk">SGilligan.co.uk</a></div> </div> </body> </html> ';
$ecm4 = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" href="../../css/style.css" /> <script language="JavaScript">
function changeimg(img_name,img_src) { document[img_name].src=img_src; } </script> </head>
<body> <div id="container"> <div id="header"></div>
<div id="nav"> <ul> <li><a href="../../index.html">Home</a></li> <li><a href="../../stocklist">Stock List</a></li> <li><a href="../../budget">Cars Under £2000</a></li> <li><a href="../../about">Info</a></li> <li><a href="../../finance">Finance</a></li> </ul> </div>
<div id="main"> <h1>'.$carname.'</h1> <div class="leftC"> <img src="'.$image1.'" alt="Larger Image" width="430" height="352" name="lrgimg"/> <center> <strong>Other Views</strong><br /> <a onClick="changeimg(\'lrgimg\',\''.$image1.'\')" style="cursor:pointer" > <img src="../../images/car.jpg" alt="Thumb" width="100" height="85" /> </a> <a onClick="changeimg(\'lrgimg\',\''.$image2.'\')" style="cursor:pointer" > <img src="../../images/porsche.jpg" alt="Thumb" width="100" height="85" /> </a> <a onClick="changeimg(\'lrgimg\',\''.$image3.'\')" style="cursor:pointer" > <img src="../../images/porsche2.jpg" alt="Thumb" width="100" height="85" /> </a> <br /> <a onClick="changeimg(\'lrgimg\',\''.$image4.'\')" style="cursor:pointer" > <img src="../../images/porsche3.jpg" alt="Thumb" width="100" height="85" /> </a> <a onClick="changeimg(\'lrgimg\',\''.$image5.'\')" style="cursor:pointer" > <img src="../../images/porsche4.jpg" alt="Thumb" width="100" height="85" /> </a> <a onClick="changeimg(\'lrgimg\',\''.$image6.'\')" style="cursor:pointer" > <img src="../../images/porsche5.jpg" alt="Thumb" width="100" height="85" /> </a></center> </div> <div class="leftC"> <p>'.$specs.'</p> </div>
<br style="clear:both;" /> <div class="space"></div>
<div class="space"></div> </div>
<div id="footer">Design by <a href="http://www.sgilligan.co.uk">SGilligan.co.uk</a></div> </div> </body> </html>';
Extra info
PHP Warnings: none received
What actually happens: Instead of the template of $ecm4 appearing, $ecm2 is displayed again, but not user submitted data is contained
Any assistance is appreactiated
|
|
|
|
05-09-2008, 07:32 AM
|
Re: Template Script strangely not working.
|
Posts: 548
Name: Mike
Location: United Kingdom
|
Hey, give this ago:
PHP Code:
<?php
$html = ''; $act = $_REQUEST['act']; $edit = $_REQUEST['edit']; $manage = $_REQUEST['manage'];
// removed for security reasons mysql_connect("", "", "") or die(mysql_error()); mysql_select_db("") or die(mysql_error());
//removed for security reasons if(isset($_COOKIE[''])) { $username = $_COOKIE['']; $pass = $_COOKIE['']; $check = mysql_query("SELECT * FROM table WHERE column = '$username'")or die(mysql_error()); } else{ header("Location: login.php"); } while($info = mysql_fetch_array( $check )){ //if the cookie has the wrong password, they are taken to the login page if ($pass != $info['password']){ header("Location: login.php"); } else { $site = $_POST['site']; $page = $_POST['page'];
// this part works if ($username == 'eurocarmarket.co.uk' and $page == 'nrmlpg') { $content = $_POST['content']; $content = nl2br($content); // look below for the contents of this file include ('eurocarmarket.php'); $title = $_POST['pgtitle']; $heading = $_POST['heading']; $ecm2 = preg_replace ('/\[title\](.*?)\[\/title\]/is', '</p><h1>$1</h1><p>', $ecm2); $ecm2 = preg_replace ('/\[b\](.*?)\[\/b\]/is', '<strong>$1</strong>', $ecm2); $ecm2 = preg_replace ('/\[i\](.*?)\[\/i\]/is', '<em>$1</em>', $ecm2); $ecm2 = preg_replace ('/\[u\](.*?)\[\/u\]/is', '<u>$1</u>', $ecm2); $ecm2 = preg_replace ('/\[img\](.*?)\[\/img\]/is', '<img src="$1" alt="Image" />', $ecm2); $ecm2 = preg_replace ('/\[url=(.*?)\](.*?)\[\/url\]/i', '<a href="$1">$2</a>', $ecm2); $ecm2 = htmlentities($ecm2);
$form = $ecm2;
$html .= '<form action="download.php" method="post"><textarea name="textarea" cols="80" rows="20">'.$form.' </textarea><input type="hidden" name="filename" value="'.$title.'"> <br><input type="submit" value="Download"></form>'; } // this part doesn't work elseif ($username == 'eurocarmarket.co.uk' and $page == 'specs') { $specs = $_POST['specs']; $specs = nl2br($specs); include ('eurocarmarket.php'); $carname = $_POST['pgtitle']; $image1 = $_POST['image1']; $image2 = $_POST['image2']; $image3 = $_POST['image3']; $image4 = $_POST['image4']; $image5 = $_POST['image5']; $image6 = $_POST['image6'];
$ecm4 = preg_replace ('/\[title\](.*?)\[\/title\]/is', '</p><h1>$1</h1><p>', $ecm4); $ecm4 = preg_replace ('/\[b\](.*?)\[\/b\]/is', '<strong>$1</strong>', $ecm4); $ecm4 = preg_replace ('/\[i\](.*?)\[\/i\]/is', '<em>$1</em>', $ecm4); $ecm4 = preg_replace ('/\[u\](.*?)\[\/u\]/is', '<u>$1</u>', $ecm4); $ecm4 = preg_replace ('/\[img\](.*?)\[\/img\]/is', '<img src="$1" alt="Image" />', $ecm4); $ecm4 = preg_replace ('/\[url=(.*?)\](.*?)\[\/url\]/i', '<a href="$1">$2</a>', $ecm4); $ecm4 = htmlentities($ecm4);
$form = $ecm4; $html .= '<form action="download.php" method="post"><textarea name="textarea" cols="80" rows="20">'.$form.' </textarea><input type="hidden" name="filename" value="'.$title.'"> <br><input type="submit" value="Download"></form>'; } else { $html .= 'No sites available'; }
} }
?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>SGilligan :: Editor</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="../css/style.css">
</head>
<body><div id="main">
<div class="logo"> </div>
<?php echo $iNav ?>
<div class="content2"> <div class="box3"> <div class="title style1" style="margin-bottom:30px">Editor - BETA</div> <div class="iBox"> <?=$html;?> </div>
</div></div>
</div> <?php echo $footer ?>
</body> </html>
What I have done is change the || to 'and', it could do nothing but it's fun to try 
__________________
Website Services
PHP Code:
if(Added_Talkupation($post) == TRUE){iHug($you);}
Last edited by rogem002 : 05-09-2008 at 07:33 AM.
|
|
|
|
05-11-2008, 09:46 AM
|
Re: Template Script strangely not working.
|
Posts: 1,572
Name: Stefan
Location: London, UK
|
Shouldn't it be '&&' not 'and'
Even so it didn't work..
Any other views?
|
|
|
|
|
« Reply to Template Script strangely not working.
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|