Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Page Refreshing

  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Page Refreshing

    I have a script where you can go in hospital but when you click the button it just refreshes the page.


    PHP Code:
    }elseif ($fetch->hospital == '0'){
    if (
    strip_tags($_POST['Submit']) && strip_tags($_POST['units'])){
    $units=intval(strip_tags($_POST['units']));
            if (
    $units == || !$units || ereg('[^0-9]',$units)){
        print 
    "Invalid amount.";
    }elseif (
    $units != && $units && !ereg('[^0-9]',$units)){
    $price $units $cost;
    if (
    $price $fetch->money){
    echo 
    "It cost's £".makecomma($cost)." for $units hour's in hospital.";
    }elseif (
    $price <= $fetch->money){
    $new_money=$fetch->money $price;
    $new_health=$fetch->health $units;
    if (
    $fetch->health == "100"){
    echo 
    "You dont need to go into the hosptial!";
    }else{
    $ime1=$units*3600;
    $new_time time('Y-m-d h:i:s') + $ime1;
    mysql_query("UPDATE accounts SET money='$new_money', htime='$new_time', hospital='1', hlong='$units' WHERE username='$username'");
    echo 
    "You are now in the hospital for $units hours!";
    echo 
    '<meta HTTP-EQUIV="REFRESH" content="0; url=hospital.php">';
    }}}}}
    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Hospital</title>
    </head>
    <link href="/style.css" rel="stylesheet" type="text/css">
    <body>

    <form name="form1" method="post" action="">
      <table width="400" border="0" align="center" class="table1px" cellpadding="0" cellspacing="0">
        <tr><td height="30" colspan="2" class="gradient">The Hospital</td></tr>
        <tr>
          <td width="51%" class="tableborder" align="right">Health wanted:</div></td>
          <td width="49%" class="tableborder" align="left"><input name="hours" type="text" class="textbox" id="hours" size="7" maxlength="5"></td>
        </tr>
        <tr>
         <td colspan="2" class="tableborder" align="center"><input name="heal" type="submit" class="custombutton" value="Go To Hospital"></td>
        </tr>
      </table>
      <br> 

  • #2
    New Coder
    Join Date
    Jan 2009
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Just refreshes the page :S

  • #3
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    it may be because you're echoing this
    PHP Code:
    echo '<meta HTTP-EQUIV="REFRESH" content="0; url=hospital.php">'
    above the head of the document.

    You may want to try:
    PHP Code:
    header("Location: ".$_SERVER['PHP_SELF']); 

  • #4
    New Coder
    Join Date
    Jan 2009
    Posts
    28
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Nope just doesn't do any thing then

  • #5
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    first sort out you code how is any one supposed to read that!

    Every time you use { all the lines before the } of the statement should be tabbed in or at less double spaced in use notepad++

    E.G
    PHP Code:
    while($hi != 'hi'){
      if(
    $hello != 'hello'){
        echo 
    'hello not sent';
      }
      
    $hi 'hi';

    See make it easy to read and for others to help you
    Working towards a Internet where we don't have website just browser applications Kill the Hyper-link and say hello to 3D Games in the browser :)

  • #6
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    echo '<meta HTTP-EQUIV="REFRESH" content="0; url=hospital.php">';

    This is creating a Redirect loop
    fix it with
    PHP Code:
    if($_GET['loop'] == '0'){
      echo 
    '<meta HTTP-EQUIV="REFRESH" content="0; url=hospital.php?loop=1">';

    Working towards a Internet where we don't have website just browser applications Kill the Hyper-link and say hello to 3D Games in the browser :)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •