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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    New Coder
    Join Date
    Jul 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts

    can't get isset to work right...

    the redirect url keeps having 'none' in the ref subid, even though I am putting the ref in this page.

    Code:
    else if(isset($_SESSION['regsuccess'])){
       /* Registration was successful */
       if($_SESSION['regsuccess']){
    	   $redr= "step2.php";
    if (isset($_GET['ref'])) {
    $ref = $_GET['ref'];
    } else {
    $ref = 'none';
    }
    $newurl= $redr.'?ref='.$ref;
    header( 'Location: '.$newurl );
             return;
       }
    note: this page submits a form, and when it comes back as successful it redirects to the new page

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Is your form action declared as POST or GET?
    If you don't have an action (though you should) it will default to GET.
    Otherwise, we don't have enough information to draw a conclusion. If the method is correct, then ensure that your form is submitting either a hidden or available field called 'ref' in order to retrieve it.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    New Coder
    Join Date
    Jul 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Is your form action declared as POST or GET?
    If you don't have an action (though you should) it will default to GET.
    Otherwise, we don't have enough information to draw a conclusion. If the method is correct, then ensure that your form is submitting either a hidden or available field called 'ref' in order to retrieve it.

    so the get ref comes from the form?

    I though it was coming from this page. like index.php?ref=2

    you're saying that this is not the case?

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Sorry I may be mistaken. I was under the impression that the form submitted to this page.
    Can you post more code for this please, or a location to see it in action? The code itself is fine, as long as the 'regsuccess' is not false, it should fetch the 'ref' from the querystring. Sounds like the regsuccess is true since you said the redirection is happening but ending up with 'none'.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #5
    New Coder
    Join Date
    Jul 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    the form submits as post to process.php

    heres code from process.php

    Code:
    /* Registration Successful */
          if($retval == 0){
             $_SESSION['reguname'] = $_POST['user'];
             $_SESSION['regsuccess'] = true;
             header("Location: ".$session->referrer);
          }

  • #6
    New Coder
    Join Date
    Jul 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    the page I posted first is the form page itself

  • #7
    New Coder
    Join Date
    Jul 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Sorry I may be mistaken. I was under the impression that the form submitted to this page.
    Can you post more code for this please, or a location to see it in action? The code itself is fine, as long as the 'regsuccess' is not false, it should fetch the 'ref' from the querystring. Sounds like the regsuccess is true since you said the redirection is happening but ending up with 'none'.
    thats right, it is redirecting to the right page... just ending in 'none' for some reason..

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Can you post the code for the first page? I assume its called step1.php.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #9
    New Coder
    Join Date
    Jul 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Code:
    <?php
    include("include/session.php");
    
    	/*	if (@$_GET['ref']) 
    		{*/
    	$refref = @$_GET['ref'];
    	/*
    		}
    		else {
    		$refref = 'something';
    		}
    		*/
    
    echo $refref;
    
    ?>
    <!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=UTF-8">
    <title>Something</title>
    <link href="css/stylesheet.css" 
    rel="stylesheet" type="text/css">
    </head>
    <body>
    <div align="center"> <br />
      <img src="images/28930.gif" /> </div>
    <div id="Tabs">
      <ul>
       <?php
    if($session->logged_in){
    	if($session->isAdmin() ){
          echo "<li><a href=\"admin/admin.php\">Admin Center</a></li>";
    	  echo "<li style='float: right;' ><a href='contributors/process.php' >Logout</a></li>";
    	  ?>
    
      <?php
       }
        else
       { 
    	echo "<li><a href='contributors/index.php' class='current'>News</a></li>";
    	echo"<li><a href='contributors/editacc.php'>Edit Account</a></li>";
    	echo "<li><a href='contributors/editgift.php'>Edit Gift</a></li>";
    	echo "<li><a href='contributors/stats.php'>Stats</a></li>";
        echo "<li><a href='contributors/promote.php'>Promote</a></li>";
        echo "<li><a href='contributors/lboard.php'>LeaderBoard</a></li>";
        echo "<li style='float: right;' ><a href='include/process.php' >Logout</a></li>";
        echo "<li style='float: right;'><a href='contributors/help.php'>Help</a></li>";
       ?>
    
      <?php
       }
    }
     else 
       {
    	?>
        <li class="with_space"><a href="index.php" class="current">Home</a></li>
    
        <li style="float: right;"><a href="contributors/index.php">Login</a></li>
        <li style="float: right;"><a href="help.php">Help</a></li>
        <?php
       }
       ?>
    	
      </ul>
    </div>
    <div id="contentbg">
     
     
    
      <?php
    /**
     * The user is already logged in, not allowed to register.
     */
    if($session->logged_in){
       echo "<h1>Registered</h1>";
       echo "<p>We're sorry <b>$session->username</b>, but you've already registered. "
           ."<a href=\"main.php\">Main</a>.</p>";
    }
    /**
     * The user has submitted the registration form and the
     * results have been processed.
     */
    else if(isset($_SESSION['regsuccess'])){
       /* Registration was successful */
       if($_SESSION['regsuccess']){
    	   $redr= "step2.php";
    if (isset($_GET['ref'])) {
    $ref = $_GET['ref'];
    } else {
    $ref = 'none';
    }
    $newurl= $redr.'?ref='.$ref;
    header( 'Location: '.$newurl );
             return;
       }
       /* Registration failed */
       else{
          header("Location: error.php");
             return;
       }
       unset($_SESSION['regsuccess']);
       unset($_SESSION['reguname']);
    }
    /**
     * The user has not filled out the registration form yet.
     * Below is the page with the sign-up form, the names
     * of the input fields are important and should not
     * be changed.
     */
    else{
    ?>
    
    <br />
    <br />
    
    <h2>Register for the event!</h2>
    <?php
    if($form->num_errors > 0){
       echo "<td><font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font></td>";
    }
    ?>
    <div align="center">
    <form action="include/process.php" method="POST" style="margin:auto">
    <table border="0" cellspacing="0" cellpadding="3">
    <tr><td>First Name:</td><td><input type="text" name="fname" maxlength="30" value="<?php echo $form->value("fname"); ?>"></td><td><?php echo $form->error("fname"); ?></td></tr>
    <tr><td>Last Name:</td><td><input type="text" name="lname" maxlength="30" value="<?php echo $form->value("lname"); ?>"></td><td><?php echo $form->error("lname"); ?></td></tr>
    <tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<?php echo $form->value("user"); ?>"></td><td><?php echo $form->error("user"); ?></td></tr>
    <tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<?php echo $form->value("pass"); ?>"></td><td><?php echo $form->error("pass"); ?></td></tr>
    <tr><td>Email:</td><td><input type="text" name="email" maxlength="50" value="<?php echo $form->value("email"); ?>"></td><td><?php echo $form->error("email"); ?></td></tr>
    <tr><td colspan="2" align="right">
    <input type="hidden" name="subjoin" value="1">
    <input type="hidden" name="ref" value="<?php echo $refref; ?>">
    <input type="submit" value="Register"></td></tr>
    </table>
    </form>
    </div>
    <div style="clear:both"></div>
    <?php
    }
    ?><br />
      <br />
    </div>
    </body>
    </html>

  • #10
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Looks ok, how are you getting to this page?
    The echo of the $refref at the top, does that show anything?
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #11
    New Coder
    Join Date
    Jul 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    yes it shows what it should show

    im getting to the page directly, using wamp on win7

  • #12
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    I'm a little at a loss.
    step2.php should be provided the querystring based on what you have here. The only thing you can do at this point is to comment out the redirection header itself, and use a print of $newurl to make sure its populated properly at this point. Since the $refref is showing data, the $_GET['ref'] is fine, and would be isset at this point.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #13
    New Coder
    Join Date
    Jul 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    heres step2.php

    Code:
    <?php
    include("include/session.php");
    if (@$_GET['ref'] && @$_GET['ref'] != 'none')
    {
    	$refref = @$_GET['ref'];
    	$ip = $_SERVER['REMOTE_ADDR'];
    
    
    	$q4 = "SELECT type FROM contips WHERE ip = '$ip'";
          $result = mysql_query ($q4, $database->connection);
    	  $result2= mysql_result($result,0);
          if(!$result2 || (mysql_numrows($result2) < 1))
    	  {
    	$q5 = "SELECT username FROM points WHERE id = '$refref'";
          $user1 = mysql_query ($q5, $database->connection);
    	  $username= mysql_result($user1,0);
    	  
    	$qcont = "INSERT INTO contips (username, type, ip) VALUES('$username', '1', '$ip')";
    	mysql_query ($qcont, $database->connection);
    	
    	$q3= "UPDATE points SET contsignups=contsignups+1 WHERE id = '$refref'";
    	  mysql_query ($q3, $database->connection);
    	
    	
    	  }
    }
    
    ?>

  • #14
    New Coder
    Join Date
    Jul 2010
    Posts
    44
    Thanks
    2
    Thanked 0 Times in 0 Posts
    it does echo/print right

    step2.php?ref=3

    ive left out the full http url to hide my site domain

  • #15
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    The problem has nothing to do with your initial page then. The problem is here:
    PHP Code:
    if(!$result2 || (mysql_numrows($result2) < 1)) 
    $result2 is the result of a mysql_result call. It will always be a scalar value. Calling mysql_numrows throws an undefined function exception, but if you use mysql_num_rows($result2) it will always return false for failure since $result2 is not a resource recordset. Therefore, your if block is always false and will never proceed from there. The correct check would be mysql_num_rows($result) < 1, assuming you want it to have a count of 0 or less.

    Also look into mysql_real_escape_string to prevent SQL injection against the $_GET['ref'] and $_SERVER['REMOTE_ADDR'].
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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