Jump to content

PHP URL Creator


arbondurant

Recommended Posts

Hi, my name is Aaron Bondurant and I'm new at this forum. I've been trying to develop a homepage script that will allow users to create a customized start page for their browser (WITHOUT having to login to anything). I've been using PHP code because it's the only code that I'm familar with. Everything I've learned has been from looking at other people's code and trying to copy it to what I want my site to do.Anyway, I want the scipt to have RSS feeds, joke of the day, pic of the day, etc. I would like it where the user can create their own personalized homepage without using MySQL or logging in to anything. And the only solution that I can come up with to pull this off is to use the following code on the homepage:

<?php{	if($a)		echo "feed 1";}{	if($b)		echo "Joke of the day";}?>

Then they will have their own link like this:

http://www.surplusmagazineshop.com/file1.php?a=1&b=1&c=1&d=1&e=1&f=1&g=1&h=1&i=1&j=1

Ex. ODD numbers only:

http://www.surplusmagazineshop.com/file1.php?a=1&b=0&c=1&d=0&e=1&f=0&g=1&h=0&i=1&j=0

I believe that this solution will do the trick. The only problem is how will the users create this URL. I know that 99% of the people that use this homepage will not know PHP or how to edit links. Therefore, I want a page where they can check off which feeds they want to display and click "Create Homepage" at the bottom. Then this will give them the full url to add as their homepage in their Internet Options menu. Thus, it will automatically give them a customized homepage that they won't have to logon to, etc.I know a little about "Mail Me" forms, but I couldn't figure out how to make a form like this. Can anyone give any suggestions?Thanks :)

Link to comment
Share on other sites

First off I will start with printing the data...

<?php$a = $_GET['a'];$b = $_GET['b'];$c = $_GET['c'];print $a;print $b;print $c?>

that code with get http://www.surplusmagazineshop.com/file1.p...amp;b=1&c=1and print 111you can add if statements

if($a != null){print $a;}

---- ---to have them change data without any knowlege, you can make a HTML form... they then fill out the form and then php will make the new URL.

<html><body><form action='changeinfo.php' method='post' />name: <input type='text' name='a' /></form></body></html>

then on page 'changeinfo.php' have something like:

<?php$a = $_POST['a'];print "<a href='http://www.surplusmagazineshop.com/file1.php?a=$a'>Go to NEW home page!!</a>";?>

in the print statement it has a=$a which will goto $a = $_POST['a'] and get what ever they put in... like there name!

Link to comment
Share on other sites

Any relation to the driving instructor?An easy way would just be to create a form that submits to the homepage using GET:<form action="homepage.php" method="get"><input type="checkbox" name="a" value="1"><input type="checkbox" name="b" value="1"><input type="checkbox" name="c" value="1"><input type="checkbox" name="d" value="1"><input type="checkbox" name="e" value="1"><input type="submit"></form>

Link to comment
Share on other sites

As far as I know, I'm not related to the driving instructor :) .Anyway, thanks for the help. I'm still having problems though. Although I have figured out how to create the url, I am having trouble getting it to where the user can add it as their homepage. Here is the "Add Homepage" code:

<a href="#" onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://mysite.com?a=1&b=1');">Click here to make this your default homepage</a>

I would like the user to have the ability to check off what info they want on their homepage, and then click a link that will automatically add it as their homepage using the code above. Is this possible?PS: I couldn't figure out how to allow them to create it under thier own name and hide the code. However, I don't think I will need this for now. Thanks anyway :)

Link to comment
Share on other sites

PS: I couldn't figure out how to allow them to create it under thier own name and hide the code.
One option would be to store their preferences in a cookie. Then whenever they come back to the site, even if they just type in the name themselves, the server will read the cookie and give them the correct settings. Cookies only work for one computer and browser, so they would need to use the same browser on the same computer to use cookies for that. But most people do..
Link to comment
Share on other sites

As for the RSS feeds, I used http://rssfeedreader.com/. They have a small link at the bottom of the feed, but I don't care because it seemed to be the easiest way to do it.Here is a page where I uploaded the feeds that I think will interest the majority of people:http://www.surplusmagazineshop.com/PIC-OF-THE-DAY/feeds.phpAnd here is the rest of the free content that I will offer for their homepage:http://www.surplusmagazineshop.com/PIC-OF-THE-DAY/index9.phpI don't know whether I should add more or if thats enough. They can pick and choose which feeds, jokes, etc to use, so maybe I should look for some more content. The way I look at it is "Would I use this as my homepage?". I will not be satisfied until I can answer yes to that.PS:I can't figure out a way to where they can edit their link. Since the link will be http://mysite.com/homepage.php?a=1&b=1, I need a way to where they can come back to the http://mysite.com/changeinfo.php page and update their info for when I add new feeds.I doubt they will be too happy if they have to completely redo all of their page options just to add a new feed. Is there any way that this could possibly be done? The only thing I can think of is to have them click "Edit" from the homepage and send them back to the changeinfo.php page WITH the "?a=1&b=1" attached. Then the checkboxes from their current homepage.php page would be checked off. Do you see what I'm saying? I don't know of a code that will automatically check off certain checkboxes by using the address bar url though.Thanks for the help. Aaron

Link to comment
Share on other sites

Hey, I'm now having some pretty big problems. I added some feeds to the homepage.php and I'm getting an error message. Here is an example of the code that I'm using:

<?php{	if($a)		echo "<div>////////////Joke of the moment </div><div><table style="border-collapse: collapse;" bordercolor="#000000" cellspacing="0" cellpadding="3" width="100%" border="1"><tbody><tr><td valign="top" width="100%"><div><strong>Joke Of The Moment</strong></div><script language="JavaScript" src="http://www.jokeornot.com/random_humor.php?feed_id=2121" type="text/javascript"></script><div> <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Powered by <a href="http://www.jokeornot.com/" target="_blank">Joke or Not</a> </font></div></td></tr></tbody></table></div>";}

And here is the error that I am getting:http://www.surplusmagazineshop.com/PIC-OF-...AY/homepage.phpIs it because of the html code that I am using on the if($a) coding?

Link to comment
Share on other sites

I don't know of a code that will automatically check off certain checkboxes by using the address bar url though.
Once you get everything that they want, such as through $_GET:
$a = $_GET['a'];$b = $_GET['b'];

etc, you can do your checkboxes like this:<input type="checkbox" name="a" value="1" <?php print ($a == "1" ? "checked" : "") ?> >That will automatically have the box checked if a is equal to 1.Your feed has issues with quotation marks being inside of the string, which is also surrounded by quotes. You can either escape your quotes by putting a \ before each one, but for a big block of text there is a much easier way:

if($a)  echo <<<END_OF_SECTION<div>////////////Joke of the moment </div><div><table style="border-collapse: collapse;" bordercolor="#000000" cellspacing="0" cellpadding="3" width="100%" border="1"><tbody><tr><td valign="top" width="100%"><div><strong>Joke Of The Moment</strong></div><script language="JavaScript" src="http://www.jokeornot.com/random_humor.php?feed_id=2121" type="text/javascript"></script><div> <font face="Verdana, Arial, Helvetica, sans-serif" size="1">Powered by <a href="http://www.jokeornot.com/" target="_blank">Joke or Not</a> </font></div></td></tr></tbody></table></div>END_OF_SECTION;

That is called a 'heredoc'. You use the <<< to tell it you are setting up a heredoc, and then give it an identifier (like "END_OF_SECTION"), and then write out whatever you want to print. It will print everything until it gets to the same identifier at the end. The catch is that the ending identifier MUST start on column 1, and it must be on its own line. There can be no spaces before it or the heredoc will not end.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...