Jump to content

ev66

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ev66's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. is there a function that can tell if a string contains only numbers ? thanks.
  2. why is i that when i click button2 and browser goes to page2 to show the value of $_SESSION['sum'] it show it as 4. It should only be 4 if clicked button1. it seems to be running the [color=red]onClick=<?php $_SESSION['sum']=4; ?>[/color]  statement regardless. any ideas ? the code is below. Thanks [b]page1.php[/b] [color=red]<?php session_start(); if (!isset($_SESSION['sum'])) {$_SESSION['sum']=10;} $sum = $_SESSION['sum']; ?>[/color] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> [color=red]<form id="form1" name="form1" method="post" action="">   <label>   <textarea name="textarea"><?php echo $sum ?></textarea>   </label> </form>[/color] <p>&nbsp;</p> [color=red]<form id="form2" name="form2" method="post" action="page1.php">   <label>   <input name="button1" type="submit" id="button1" [color=green]onClick=<?php $_SESSION['sum']=4; ?>[/color] value="Minus"/>   </label> </form>[/color] [color=purple][color=orange]<form id="form3" name="form3" method="post" action="page2.php">   <label>   <input name="button2" type="submit" id="button2" value="go" />   </label> </form>[/color][/color] <p>&nbsp;</p> </body> </html> [b]page2.php[/b] [color=red]<?php session_start(); $sum = $_SESSION['sum'];?>[/color] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body>[color=red]<?php echo $sum ?>[/color] </body> </html>
  3. ev66

    Syntax help

    Thanks. It works now.
  4. In the code below im trying to echo an image using a variable $a but cant get it to work.It works if i use the image name, but cant get it to work using the variable, any ideas please ? Thanks [color=green]THIS DOESNT WORK[/color] [color=red]<?php $a = "ad_ink-spot.gif"; ?>[/color] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <p></p> <p>&nbsp;</p> <p>[color=red]<?php echo '<a href=' . $_SERVER['PHP_SELF'] . '><img src=images/' . $a . 'width=200 height=121 border=0 /a>'; ?>[/color]&nbsp;</p> </body> </html> [color=green]THIS DOES WORK[/color] [color=red]<?php $a = "ad_ink-spot.gif"; ?>[/color] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <p></p> <p>&nbsp;</p> <p>[color=red]<?php echo '<a href=' . $_SERVER['PHP_SELF'] . '><img src=images/ad_ink-spot.gif width=200 height=121 border=0 /a>'; ?>[/color]&nbsp;</p> </body> </html>
  5. thanks wildteen88, i used your 2nd example, works now. ta
  6. Im using this code below to place the value of $a into first cell of a table, what is the correct syntax so that i only have to use one echo statement ? tried all diff combinattions but cant get it. Thanks <body>[color=red]<?php[/color] [color=blue]echo '<table width="400" border="1">   <tr>     <td>'; echo $a; echo '&nbsp;</td>[/color]     <td>&nbsp;</td>     <td>&nbsp;</td>   </tr>   <tr>     <td>&nbsp;</td>     <td>&nbsp;</td>     <td>&nbsp;</td>   </tr>   <tr>     <td>&nbsp;</td>     <td>&nbsp;</td>     <td>&nbsp;</td>   </tr> </table> ' [color=red]?>[/color]
  7. But in javascript, when a button is clicked isnt the page refreshed ?  so why not just refresh when using a php page ?
  8. I am writing a shopping cart app using php but have noticed most shopping cart apps are wrote in javascrirt, whats the advantages of javascript ? isnt php easier and more secure ? Thnaks Evan
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.