iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-02-2005, 08:03 PM
MrLeN's Avatar
WebProWorld Veteran
 
Join Date: Jul 2003
Location: Melbourne, Australia
Posts: 381
MrLeN RepRank 0
Default Making a page from a form..

I want to create a form, where if someone enters a keyword, a page is generated.

ie:

Someone enters:

"skateboard"

The form will craete skateboard.php and also, automatically place "skateboard" in the top of that page as a variable:

ie:

$keyword = skateboard

How would I go about doing this with php?

MrLeN
Reply With Quote
  #2 (permalink)  
Old 10-03-2005, 12:38 AM
MrLeN's Avatar
WebProWorld Veteran
 
Join Date: Jul 2003
Location: Melbourne, Australia
Posts: 381
MrLeN RepRank 0
Default

ok here is what I have:

Code:
<html>
<body><form action="create.php" method="GET">
Please enter Search Term: <input type="text" name="id" value="">
<input type="submit" />
</form></body>
</html>
Code:
<?php 

// generate.php - creates the page identified in 'id' and creates a page out of it 

if (isset($_GET['id']) && !empty($_GET['id'])) { 

  $pagetemplate = '
  <?php $file = "http://news.search.yahoo.com/news/rss?p='.$_GET['id'].'+&mp;ei=UTF-8&mp;fl=0&mp;x=wrt"; ?>
                   <html> 
                   <head> 
                     <title>'.$_GET['id'].'</title> 
                   </head> 
                  
                   <body> 
                     <h1>'.$_GET['id'].'</h1> 
					 <? include("parser.php"); ?>
                   </body> 
                   </html>'; 

  $file = "html/".$_GET['id'].".php"; 
   
  if (!$handle = fopen($file, "a")) { 
    die("Cannot Open File"); 
  } 

  if (!fwrite($handle, $pagetemplate)) { 
      die("Cannot Write to File"); 
  } 

  echo "Your resluts have been generated. Please click here to see them."; 

  fclose($handle); 
} 

?>
and here is what it does:

http://www.mrlen.com/submit.php

Now, I have a new problem. The Yahoo! RSS URL requires that each search term has a + separating the search terms. So far I can't add kore than a singlar search term.

ie:

Hurricane will work
Hurricane Katrina will not work

Can someone help me with this problem?

Also, how can I change it so that after submitting it goes straight to the generated page? I don't want o click to see results.

Also, if I enter the same search term twice, it will add it to the same page twice. How can I fix that?

MrLeN
Reply With Quote
  #3 (permalink)  
Old 10-03-2005, 02:08 AM
ADAM Web Design's Avatar
WebProWorld 1,000+ Club
 
Join Date: Dec 2003
Location: Toronto, Ontario, Canada
Posts: 2,181
ADAM Web Design RepRank 1
Default

I don't know PHP very well (read: next to nil), but could you not run a replace function to replace spaces with + signs before you processed any of the form input?

Sorry I can't help you much more than to give you a suggestion.
Reply With Quote
  #4 (permalink)  
Old 10-03-2005, 02:25 AM
MrLeN's Avatar
WebProWorld Veteran
 
Join Date: Jul 2003
Location: Melbourne, Australia
Posts: 381
MrLeN RepRank 0
Default

Thanks mate.

Actually, that part is all cool.

I fixed it with:

<?php $file = "http://news.search.yahoo.com/news/rss?p='.urlencode($_GET['id']).'&ei=UTF-8&fl=0&x=wrt"; ?>

Now I still have my other two problems.

1 - To redirect after the script has created the pages, because I don't want that middle page where it says click to see results.

2 - If I enter the same search term twice, it will add it to the same page twice.

Oh and there's a third issue: I need to try and limit the search box so that people cannot enter more than two words. Because the RSS doesn't work with any phrases larger than two words.

I am getting there though. Can anyone help me with these things?

MrLeN
Reply With Quote
  #5 (permalink)  
Old 10-03-2005, 10:06 AM
MrLeN's Avatar
WebProWorld Veteran
 
Join Date: Jul 2003
Location: Melbourne, Australia
Posts: 381
MrLeN RepRank 0
Default

It's ok everyone. I have completed everything I need. Thanks :)

MrLeN
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:41 PM.



Search Engine Optimization by vBSEO 3.3.0