1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

php in html forms problem

Discussion in 'PHP' started by izlik, Mar 18, 2013.

  1. #1
    Hello. I have this code that get's the number in this url http://mysite.com/flash.php?flash=1

    it works as it should but the next & previous & Random buttons is not working, with the code bellow if i press them the url jsut changes to http://mysite.com/flash/index.php? and "flash=X" is not even appearing, why is this ?


    $play = $_GET['flash'];
    <center>
                <style type="text/css">
                form {display : inline;}
                </style>
              <FORM METHOD="LINK" ACTION="index.php?flash=<? echo "$play++"; ?>"> <INPUT TYPE="submit" VALUE="Next >>"></form>
              <FORM METHOD="LINK" ACTION="index.php?flash=<? echo "$random2"; ?>"> <INPUT TYPE="submit" VALUE="<< Random >>"></form>
            <FORM METHOD="LINK" ACTION="index.php?flash=<? echo "$play--"; ?>"> <INPUT TYPE="submit" VALUE="<< Previous"></form>
              <? include 'foot.php'; ?>
                  </center>
    PHP:
     
    Solved! View solution.
    izlik, Mar 18, 2013 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    Try this syntax instead <?=$play++; ?>

    Also if you look at the source code of your page, you will notice that flash= does exist, if your using rewrite urls its possible thats what causing it to disappear...
     
    MyVodaFone, Mar 18, 2013 IP
  3. izlik

    izlik Well-Known Member

    Messages:
    2,399
    Likes Received:
    50
    Best Answers:
    0
    Trophy Points:
    185
    #3
    Hey!

    Same problem, Even if i do this <FORM METHOD="LINK" ACTION="index.php?flash=2"> <INPUT TYPE="submit" VALUE="Next >>"></form> "?flash=2" will not appear in the URL even if i press "next" :/

     
    izlik, Mar 18, 2013 IP
  4. #4
    Why do you use a form for each form?

    Why not use just a link?
    <a href="index.php?flash=<? echo "$play++";">Next >></a>
    PHP:
     
    daniel_r, Mar 18, 2013 IP
  5. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #5
    Look at the url, before you click it...
    are you using htaccess rewrite rules ?
     
    MyVodaFone, Mar 18, 2013 IP
  6. ArMouR

    ArMouR Well-Known Member

    Messages:
    161
    Likes Received:
    22
    Best Answers:
    0
    Trophy Points:
    130
    Digital Goods:
    1
    #6
    Please try
     
    ArMouR, Mar 19, 2013 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #7
    Not only does your opening and closing of PHP make no sense, you're code makes little to no sense... why (as daniel_r said) are you wasting a form and submit to do an anchor's job? Why are you using HTML 3.2 in writing the page? The mere presence of inlined CSS and a CENTER tag means whatever page this is going into needs to be thrown out and started over.

    Of course, your REAL problem is that you didn't close php before you started your markup after setting $play. Do you see a ?> in there? Again though, why if I had my way <?php ?> would be removed from PHP entirely as pointless, redundant, and possibly a security risk.

    That's one hell of a mess of nonsense for what should probably be a LIST (since it's related choices) containing ANCHORS... preferably not constantly opening and closing PHP for no good reason.

    $play = $_GET['flash'];
    
    echo '
    	<ul class="nextRandomPrev">
    		<li>
    			<a href="index.php?flash=',$play+1,'">Next &raquo;</a>
    		</li><li>
    			<a href="index.php?flash=',$random2,'">&laquo; Random &raquo;</a>
    		</li><li>
    			<a href="index.php?flash=',$play-1,'">&laquo; Previous</a>
    		</li>
    	</ul>';
    	
    include('foot.php');
    
    Code (markup):
    Assumes you are already inside <?php ?>

    You want to make them look like form inputs, that's what CSS is for -- usually you can even style them more attractive than form inputs and more reliably thanks to CSS3. I suspect you were chosing tags either based on their appearance, or from not understanding that if all you are sending is getdata, you don't need a form.

    .. and to be frank, if you are using STYLE as a tag, STYLE as an attribute, or tags like CENTER, you're doing it ALL WRONG in all but the rarest of circumstances. CENTER in particular says "look at me, I can haz intarnets style 1997?"

    Again, the wrong markup doing the wrong job!
     
    deathshadow, Mar 19, 2013 IP