web page maker- I get a blank page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hoku_2000
Forum Newbie
Posts: 8
Joined: Wed Apr 29, 2009 11:50 pm

web page maker- I get a blank page

Post by hoku_2000 »

I am teaching myself php and I had always wondered how web page makers are made. So far, I think I am on a good track, however, when I test my page, my results dont show up I just get a blank page. Can someone please tell me what I am doing wrong?

Thanks!

HTML form

Code: Select all

<!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=iso-8859-1" />
<title>Web Page Generator</title>
<script type="text/javascript">
    function formReset()
{
document.getElementById("webPageGeneratorForm").reset()
}
</script>
</head>
<body bgcolor="purple">
 
<center><h1>Web Page Generator</h1></center>
 
 
<form action="webPageGenerator.php" method="POST" id="webPageGeneratorForm"> 
 
<center><b>Enter your page title:</b><br/> <input type="text" name="pageTitle" /><br /><br 
 
/></center>
 
 
<center><b> Choose your background color:<b><br/> 
<td>
<input type = "radio"
       name = "pageBackground"
       value = "pink" 
       checked = "checked" /><font color="pink">Pink</font><br />
<input type = "radio"
       name = "pageBackground"
       value = "teal" /><font color="teal">Teal</font><br />
<input type = "radio"
       name = "pageBackground"
       value = "blue" /><font color="blue">Blue</font><br />
<input type = "radio"
       name = "pageBackground"
       value = "lime" /><font color="lime">Lime</font></a> <br/>
</td>
</tr>
</table><br/></center>
 
<center><b> Choose your text color:<b><br/> 
<td>
<input type = "radio"
       name = "textColor"
       value = "black" 
       checked = "checked" />Black<br />
<input type = "radio"
       name = "textColor"
       value = "maroon" /><font color="maroon">Maroon</font><br />
<input type = "radio"
       name = "textColor"
       value = "red" /><font color="red">Red</font><br />
<input type = "radio"
       name = "textColor"
       value = "yellow" /><font color="yellow">Yellow</font></a> <br/>
</td>
<br/>
</center>
 
 
<center>
<b>Pick your font:</b></br>
<td>
<select name = "pageFont">
  <option value = "arial">Arial</option>
  <option value = "helvetica">Helvetica</option>
  <option value = "times">Times</option>
  <option value = "serif">Serif</option>
  <option value = "verdana">Verdana</option>
</select>
</td>
</center><br/><br/>
 
 
<center><b>Enter up to 7 links:</b><br/>
<b>Link 1:</b><input type="text" name="url" /><br /><br/> 
<b>Label:</b><input type="text" name="label" /><br /><br/>
<b>Link 2:</b><input type="text" name="url" /><br /><br/> 
<b>Label:</b><input type="text" name="label" /><br /><br/>
<b>Link 3:</b><input type="text" name="url" /><br /><br/> 
<b>Label:</b><input type="text" name="label" /><br /><br/>
<b>Link 4:</b><input type="text" name="url" /><br /><br/> 
<b>Label:</b><input type="text" name="label" /><br /><br/>
<b>Link 5:</b><input type="text" name="url" /><br /><br/> 
<b>Label:</b><input type="text" name="label" /><br /><br/>
<b>Link 6:</b><input type="text" name="url" /><br /><br/> 
<b>Label:</b><input type="text" name="label" /><br /><br/>
<b>Link 7:</b><input type="text" name="url" /><br /><br/> 
<b>Label:</b><input type="text" name="label" /><br /><br/>
</center>
 
<p><center><b>Below you may fill out three (3) paragraphs with the desired 
 
content.</b></p></center>
 
 
<center><b>Paragraph 1<b><br/><br/><br/><br/><textarea name="pageText" cols="40" 
 
rows="5"></textarea></center><br /><br /><br/>
 
<center><b>Paragraph 2<b><br/><br/><br/><br/><textarea name="pageText" cols="40" 
 
rows="5"></textarea></center><br /><br /><br/>
 
 
<center><b>Paragraph 3<b><br/><br/><br/><br/><textarea name="pageText" cols="40" 
 
rows="5"></textarea></center><br /><br /><br/>
<center><input type="submit" name="submit" value="Make My Page"><input type="button" 
 
onclick="formReset()" value="Clear"></center>
</form> 
</body>
</html>

PHP Code

Code: Select all

<!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">
 
<?php 
$pageTitle = $_POST["pageTitle"]; 
$pageBackground = $_POST["pageBackground"];
$textColor = $_POST["textColor"];
$pageFont = $_POST["pageFont"];
 
 
$url = $_POST["url"];
$label = $_POST["label"]; 
for ($u=0; $u <7; $u++) {
        if ($url[$u] != "" and $label[$u] != "")}
 
 
 
 
$pageText = $_POST["pageText"];
 
?> 
 
 
<head> 
<title><?php echo $pageTitle; 
?>
</title> 
</head> 
 
 
<html>
<body style="font-family: $pageFont; color: $textColor; background-color: $pageBackground"> 
text-align: center; font-size: 14pt">$pageText</p>
 
 
<b><u><center><?php echo $pageTitle; ?></b></u></center>
<br /><br />
 
 
<center><p>
<?php echo $pageText; ?></p></center>
 
 
 
</body> 
</html> 
 
 
Last edited by Benjamin on Sat May 02, 2009 7:25 pm, edited 1 time in total.
Reason: Changed code type to php, html.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: web page maker- I get a blank page

Post by califdon »

I think you need to find a better teacher. I can't even figure out what you were trying to do. Within a file, all PHP code must be in blocks. Yours is not. It has to be structured like this:

Code: Select all

...
<?php
   ...  (PHP code here)  ...
?>
   ...  (HTML code here)  ...
<?php
   ...  (PHP code here)  ...
?>
   ... and so on.
Likewise, your if() statement has no action to be taken, since there's nothing in the if() block. Also, you should use the boolean operator &&, not the word "and".

Are you teaching yourself from a book? Or a tutorial? If you're not doing one of the two, I would give you little hope of ever learning how to code in PHP.
hoku_2000
Forum Newbie
Posts: 8
Joined: Wed Apr 29, 2009 11:50 pm

Re: web page maker- I get a blank page

Post by hoku_2000 »

Book and Tutorials.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: web page maker- I get a blank page

Post by califdon »

Have you ever gotten a PHP script to run? If not, you should start with tutorials that let you begin to understand how to structure a script. As I said, your code doesn't make any sense to me. What are you trying to do when you loop through the links boxes from your form? Why do you have 2 text areas with the same name? What is that line that follows your <body> tag in the PHP script? You have to be much clearer in your thinking and careful in your coding, if you are ever going to learn how to write a successful script.
hoku_2000
Forum Newbie
Posts: 8
Joined: Wed Apr 29, 2009 11:50 pm

Re: web page maker- I get a blank page

Post by hoku_2000 »

Yes, I have gotten a php script to run. I've been doing the examples from my book and tutorials. I figured that doing something not out of the book would give me more of a challenge. When I loop through the link boxes, I am trying to allow the user to enter 7 or less links. I have 2 text areas with the same name because thats where the user can enter different content. The line below the body tag, I just took it out because I realized that I didnt need it. It was formatting something I had, that I took out.
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: web page maker- I get a blank page

Post by McInfo »

Run your HTML through the W3C Markup Validation Service.

Edit: This post was recovered from search engine cache.
Post Reply