Jump to content

TheEddy

Members
  • Posts

    32
  • Joined

  • Last visited

    Never

Posts posted by TheEddy

  1. It was better for me to use this:

    function curPageURL() {
    $pageURL = 'http';
    if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80") {
      $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
      $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return $pageURL;
    }
    $r=curPageURL();
    $_SESSION['REFERER']=$r;
    

     

    Because I also needed to record the direct input from the browser.  Thanks for your help though!

  2. mysql_fetch_assoc stores the values in an array. So you could either use the list function like:

     

    while(list($uid,$userName) = mysql_fetch_assoc($result)){

     

    Or when you print the HTML you would do something like

     

    echo "<li><a href=\"membersprofiles.php?uid=".$row['uid']."\" title=\"".$row['userName']."\">".$row['userName']."</a></li>\n";

    That doesn't work btw.
  3.   if (mysql_num_rows($result) != 0) {
      print ("
      <ul>
      ");
        while ($row = mysql_fetch_assoc($result)){
      print ("
      <li><a href=\"memberprofiles.php?uid=$uid\" title\"$userName\">$userName</a></li>
      ");
    exit;
    }
      print ("
      </ul>
      ");
      }
      else {
        print ("
    There were no results based on your criteria.
    ");
    }

     

    I don't know how I made that mistake where I had that equal to 1.  But I don't know how to loop the results :(

  4. That looks like it would work as written. Have you echoed the query string to make sure it contains the values it should contain?

    This is what I have for results:

     

    $sql = "SELECT * FROM `users` WHERE `$searchField` LIKE '%$search%'";
    $result = mysql_query($sql) or die(mysql_error());
    $row = mysql_fetch_array($result);
    $userName = $row['userName'];
    $uid = $row['userID'];
    
      if (mysql_num_rows($result) == 1) {
      print ("
      <ul>
      ");
        while ($row = mysql_num_rows($result)){
          print ("
      <li><a href=\"memberprofiles.php?uid=$uid\" title\"$userName\">$userName</a></li>
      ");
    exit;
        }
      print ("
      </ul>
      ");
      }
      else {
        print ("
    There were no results based on your criteria.
    ");
    }

  5. Post an example of the search term you used and the data in the database that you feel it should have returned.

    $searchField would have been "emailAddress" and $search should have been "webmaster" and should have pulled:

     

    webmaster@test.com and webmaster@testing.com

  6. <?php
    $pageTitle='Edit Profile';
    require_once ("header.php");
    ?>
    

    How can I pass a variable like that through header.php?  I know it doesn't work the way I have it.

     

    What doesn't work?  If you echo $pageTitle in header.php it will work, unless header.php has already been included/required.

    I am an idiot, I see the problem now haha.

     

    I had:

    <title>$pageTitle</title>

    in header.php and it displayed $pageTitle  as the title.

  7. <script type="text/javascript">
            var $J = jQuery.noConflict();
            jQuery(document).ready(function($){
                    $J("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
            });
         // Use Prototype with $(...), etc.
         $('div').hide();
    
    </script>

     

    Like that?

  8. you need to use an update query instead of insert.

    <?php
    require_once ("dbconn.php");
    ?>
    <?php
    $userID = $_SESSION['userID'];
    $insert_query = 'UPDATE users 
                     SET aim="' . $_POST['aim'] . '",
    			     msn="' . $_POST['msn'] . '",
    			     yim="' . $_POST['yim'] . '",
    			     psnID="' . $_POST['psnID'] . '",
    			     xblGamertag="' . $_POST['xblGamertag'] . '",
    			     otherContact="' . $_POST['otherContact'] . '",
    			 WHERE userID = $userID;'
    
    
    mysql_query($insert_query);
    
    ?>

     

    It says I did something wrong but I can't find it :(

  9. <?php
    if(!isset($_SESSION))
    {
    session_start();
    }
    // UNCOMMENT NEXT LINE TO PRINT THE $_SESSION ARRAY TO THE SCREEN . . .
    // echo '<pre>'; print_r($_SESSION); echo '</PRE>';
    if(empty($_SESSION['userID']) || $_SESSION['authorized'] != true ) {
    
    
    
    header("Location: login.php");
    
    
    
    exit;
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="content-type" content="text/xml; charset=utf-8" />
    <meta http-equiv="refresh" content="5;url=editprofile.php">
        <title>Saving Profile</title>
      </head>
    
      <body>
    <?php
    require_once ("dbconn.php");
    ?>
    <?php
    $userID = $_SESSION['userID'];
    $insert_query = 'insert into users WHERE userID='$userID'(
    				aim,
    				msn,
    				yim,
    				psnID,
    				xblGamertag,
    				otherContact
    				) 
    				values
    				(
    				"' . $_POST['aim'] . '", 
    				"' . $_POST['msn'] . '",
    				"' . $_POST['yim'] . '",
    				"' . $_POST['psnID'] . '",
    				"' . $_POST['xblGamertag'] . '",
    				"' . $_POST['otherContact'] . '"
    				)';
    
    mysql_query($insert_query);
    
    ?>
    Your profile has been saved!  You will now be redirected from where you came from.
    <br /><a href="editprofile.php" title="Click here if you don't want to wait">Click here if you don't want to wait.</a>
      </body>
    </html>

     

    It creates a new record but I want it to update an existing one.  It's an editprofile script.

  10. You posted some more while I was writing, I guess. In the editprofile.php script, the session_start() needs to be before any attempt to use a $_SESSION var. You should also check specifically for the $_SESSION array element you need to be set. This is untested, but it should work as written. Let me know if it doesn't . . .

     

    <?php
    session_start();
    // UNCOMMENT NEXT LINE TO PRINT THE $_SESSION ARRAY TO THE SCREEN . . .
    // echo '<pre>'; print_r($_SESSION); echo '</PRE>';
    if(empty($_SESSION['userID']) || $_SESSION['authorized'] != true ) {
    header("Location: login.php");
    exit;
    } else {
    
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="content-type" content="text/xml; charset=utf-8" />
        <title>Edit Profile</title>
        <style type = "text/css">
          table {
            margin: 0 auto;
        </style>
      </head>
      <body>
    <?php
    require_once ("dbconn.php");
    $result = mysql_query("SELECT * FROM `users` WHERE `userID` = '{$_SESSION['userID']}' LIMIT 1") or die(mysql_error());
    $row = mysql_fetch_array($result);
    $userName = $_SESSION['userID'];
    print ("Testing.  Your ID is $userID<br /><a href=\"http://localhost/mgnml/logout.php\">Log Out</a></body></html>");
    }
    ?>
    

     

    Had to also make some changes to the other code.  Now it works.  Thanks for the help!

×
×
  • 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.