HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Need simple link code.
Post new topic   Reply to topic    HTML Help Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Newbie101



Joined: 09 Oct 2008
Posts: 35

PostPosted: Thu Oct 16, 2008 10:42 am     Need simple link code. Reply with quote

I have everything working on my quiz site, (thanks to this site. Laughing )

My problem is Very simple, but I cannot find the code to direct my if statement to another link.

I can find 1000 examples of using an if statement to echo.

Code:
if ( $my_name == "happyfeet" ) {
   echo "Your name is happyfeet!<br />";


but I am trying to make a "simple link" and have searched through samples. I should be able to have a link without anchors in there.

I am trying stuff like

Code:
<?php
session_start();   

if ($_SESSION['pages'] == $_SESSION['tries']) {
    header( "Location: http://www.my webpage.com/endresultpage.php" );
  }

Both session pages have working numerical values and I have manipulated them successfully. Adding to page value for how many questions they've answered, etc.

The same way you guys get stuck on superadvanced code I am gettin tripped up on little things. I know its only 1 line of code I'm looking for but I've been at it for 3 hours and can't seem to find it in any tutorial. I searched here and only found 1 similiar request in which I added that i was looking for it to.

thanks in advance, maybe I won't always be a newbie. lol
jonhel



Joined: 07 Oct 2008
Posts: 10
Location: Adelaide, South Australia

PostPosted: Thu Oct 16, 2008 12:21 pm     Reply with quote

Just to clarify are you wanting your script to run
http://www.mywebpage.com/endresultpage.php
subject to the conditions being met or do you want to provide the user with a hyperlink to click?

What error do you get when using the piece of code you provided with the header statement?


Jonathan
Newbie101



Joined: 09 Oct 2008
Posts: 35

PostPosted: Thu Oct 16, 2008 2:02 pm     Reply with quote

Yes! exactly.

I would "simply" (lol. not if you don't know), like to be able to forward people to my endpage.php if my conditions are met. No hyperlink. I tried using similiar code to anchor tags, but without the anchors.

My quiz sends people to random questions. I am counting "correct answers" and "amount of questions asked" in sessions using php. I have got everything to work as far as changing values.

My main resource for learning code is google and tutorials. I am getting a blank page if I insert that "if statement". If I leave it out I am getting the normal document of that page. I am just not sure how to make a working if statement link in php.

I spent all morning googling if statements and php tutorials. I had some different attempts some with location/redirect/and the above header sample. I am too much of a newbie to know if it is a bug, or if I'm way off track.
Thanks
jonhel



Joined: 07 Oct 2008
Posts: 10
Location: Adelaide, South Australia

PostPosted: Thu Oct 16, 2008 10:07 pm     Reply with quote

You're on the right track with the header statement. Is there html code on the page before this if statement?

If there is, then the header statement will not work and it is very "fussy" with blank lines etc. You'll likely get an error along the lines of "headers already sent".

There is a way around this but I won't overburden you with it unless it's needed Smile

Resulting blank pages often occur due to not having matching curly braces { to open and close conditionals. It's hard to comment further without seeing all the code for the page.

Also have you terminated the php code section with ?>


Jonathan
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> PHP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial