|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| 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
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
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
__________________
TubeShine - YouTube Playlist Generator |
|
||||
|
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'].'+∓ei=UTF-8∓fl=0∓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);
}
?>
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
__________________
TubeShine - YouTube Playlist Generator |
|
||||
|
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.
__________________
Toronto Web Design | Search Engine Friendly, Standards-Compliant Layouts | Walk on my Path (my blog) |
|
||||
|
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
__________________
TubeShine - YouTube Playlist Generator |
|
||||
|
It's ok everyone. I have completed everything I need. Thanks :)
MrLeN
__________________
TubeShine - YouTube Playlist Generator |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |