Jump to content

tqla

Members
  • Posts

    366
  • Joined

  • Last visited

Posts posted by tqla

  1. Works great.

    Thank you so darn much MemphiS.

    Everyday i learn a little more. (I hope to be as good at this as you someday!)

    I hope this bit of code helps somebody else too!

     

    Long live php!! (sorry so overzealous, just happy about this that's all)

  2. Hi, I am working on a Change Password script. It actually does work in that it changes the password but it's not handling the else's and if's properly. It's supposed to not update  if the $newpassword and $confirmnewpassword variables do not match, but it goes ahead and updates anyway even if they don't. What's more, the Congratulations message appears all the time whether it updates or not. 

     

     

    <?php 
    
    session_start();
    
    require_once('Connections/Auth.php'); 
    $connection = mysql_connect($hostname_Auth, $username_Auth, $password_Auth) 
    or die ("Couldn't connect to server.");
    $db = mysql_select_db($database_Auth, $connection)
    or die ("Couldn't select database.");   
    
    $password = $_POST['password'];
    $newpassword = $_POST['newpassword'];
    $confirmnewpassword = $_POST['confirmnewpassword'];
    
    $result = mysql_query("SELECT password FROM Member WHERE loginName='{$_SESSION['MM_Username']}'");
    if(!$result) 
    { 
    echo "The username you entered does not exist"; 
    } 
    elseif($password!= mysql_result($result, 0)) 
    { 
    echo "You entered an incorrect password"; 
    } 
    if($newpassword=$confirmnewpassword) 
        $sql=mysql_query("UPDATE Member SET password='$newpassword' where loginName='{$_SESSION['MM_Username']}'"); 
        if($sql) 
        { 
        echo "Congratulations You have successfully changed your password"; 
        }
    else
    { 
    echo "The new password and confirm new password fields must be the same"; 
    }  
    ?> 
    

  3. hi MadTechie. Here's the code.

     

    
    <?php
    ob_start(); 
      session_start();  
      ?>
    <link href="styles.css" rel="stylesheet" type="text/css">
    <html>
    <body>
    <div id="containerDiv">
    <div id="header">
    <h1>Become a member!</h1><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent quis quam nec metus accumsan imperdiet. Nulla nisl velit, feugiat sed, pellentesque nec, laoreet vitae, massa. Suspendisse potenti. Donec sit amet libero et nisl facilisis varius. Aliquam faucibus rhoncus velit. Nullam ligula urna, auctor vitae, bibendum tincidunt, egestas sit amet, neque. Nulla nunc lectus, luctus ut, adipiscing vitae, egestas in, quam. Fusce non diam. Quisque diam. Fusce urna magna, aliquam cursus, suscipit sit amet, porta in, arcu. Cras eleifend, turpis id dictum fringilla, sapien enim placerat nisl, mollis congue nisl pede nec purus. Nam ante. Integer ipsum. Quisque vitae lorem. In non turpis. In tincidunt. Morbi at mauris. Praesent dignissim rutrum ligula.</p>
    <div id="form">
    <?php
                                     
      include("db.inc.php");                                    
      switch (@$_GET['do'])                                   
      {
        case "login":                                         
        
    
          $sql = "SELECT loginName FROM Member 
                  WHERE loginName='$_POST[fusername]'";       
          $result = mysql_query($sql)
                      or die("Couldn't execute query.");      
          $num = mysql_num_rows($result);                     
          if ($num == 1)  // login name was found             
          {
             $sql = "SELECT loginName FROM Member 
                     WHERE loginName='$_POST[fusername]'
                     AND password='$_POST[fpassword]'";
             $result2 = mysql_query($sql)
                       or die("Couldn't execute query 2.");   
             $num2 = mysql_num_rows($result2);
             if ($num2 > 0)  // password is correct           
             {
               $_SESSION['auth']="yes";                       
               $logname=$_POST['fusername']; 
               $_SESSION['logname'] = $logname;               
               $today = date("Y-m-d h:i:s");                  
               $sql = "INSERT INTO Login (loginName,loginTime)
                       VALUES ('$logname','$today')";
               mysql_query($sql) or die("Can't execute query.");
               header("Location: Member_page.php");           
             }
             else    // password is not correct               
             {
               unset($_GET['do']);                            
               $message="<p><font color=#ff0000>The Login Name, '$_POST[fusername]' 
                         exists, but you have not entered the 
                         correct password! Please try again.</font></p>";
               include("form.inc");                     
             } 
          }                                                   
          elseif ($num == 0)  // login name not found         
          {   
             unset($_GET['do']);                              
             $message = "<p><font color=#ff0000>The Login Name you entered does not 
                         exist! Please try again.</font></p>";
             include("form.inc");
          }
        break;                                                
    
        case "new":                                           
          foreach($_POST as $field => $value)                 
          {
            if ($field != "fax")                              
            {
              if ($value == "")                               
              {
                unset($_GET['do']);
                $message_new = "<p><font color=#ff0000>Required information is missing. Please try again.</font></p>";
                include("form.inc");
                exit();
              }
            }
            if (ereg("(Name)",$field))                        
            {
             /*if (!ereg("^[A-Za-z' -]{1,50}$",$value)) 
             {
               unset($_GET['do']);
               $message_new = "$field is not a valid name. 
                                Please try again.";
               include("form.inc");
               exit();
             }*/
            }
            $$field = strip_tags(trim($value));               
          } // end foreach
          if (!ereg("^[0-9]{5,5}(\-[0-9]{4,4})?$",$zip))      
          {
            unset($_GET['do']);
            $message_new = "<p><font color=#ff0000>$zip is not a valid zip code. 
                            Please try again.</font></p>";
            include("form.inc");
            exit();
          }
          if (!ereg("^[0-9)(xX -]{7,20}$",$phone))            
          {
            unset($_GET['do']);
            $message_new = "<p><font color=#ff0000>$phone is not a valid phone number. 
                            Please try again.</font></p>";
            include("form.inc");
            exit();
          }
          if ($fax != "")                                    
          {
            if (!ereg("^[0-9)(xX -]{7,20}$",$fax)) 
            {
              unset($_GET['do']);
              $message_new = "<p><font color=#ff0000>$fax is not a valid phone number. 
                               Please try again.</font></p>";
              include("form.inc");
              exit();
            }
          }
          if (!ereg("^.+@.+\\..+$",$email))                  
          {
            unset($_GET['do']);
            $message_new = "<p><font color=#ff0000>$email is not a valid email address. 
                             Please try again.</font></p>";
            include("form.inc");
            exit();
          }                                                  
          /* check to see if login name already exists */
    
          $sql = "SELECT loginName FROM Member 
                    WHERE loginName='$newname'";
          $result = mysql_query($sql)
                    or die("Couldn't execute query.");
          $num = mysql_numrows($result);
          if ($num > 0)                                      
          {
            unset($_GET['do']);
            $message_new = "<p><font color=#ff0000>$newname already used. Select another
                             Member ID.</font></p>";
            include("form.inc");
            exit();
          }
          else                                               
          {   
            $today = date("Y-m-d");                          
            $sql = "INSERT INTO Member (loginName,createDate,
                      password,firstName,lastName,street,city,
                      state,zip,phone,fax,email) VALUES
                    ('$newname','$today','$newpass',
                     '$firstName', '$lastName','$street','$city',
                     '$state','$zip','$phone','$fax','$email')";
            mysql_query($sql);                               
            $_SESSION['auth']="yes";                         
            $_SESSION['logname'] = $newname;                 
            /* send email to new member */                   
            $emess = "A new Member Account has been setup. ";
            $emess.= "Your new username and password are: ";
            $emess.= "\n\n\tUsername: $newname\n\t Password: $password\n\n";
            $emess.= "If you have any questions or problems,";
            $emess.= " email xxx@xxx.com";
            $ehead="From: xxx@xxx.com\r\n";     
            $subj = "Your new Member Account";
            $mailsend=mail("$email","$subj","$emess","$ehead");
            header("Location: New_member.php");              
          }
        break;                                               
    
        default:                                             
            include("form.inc");
      }
      ob_end_flush(); 
    ?>
    
    
    </div>
    </div>
    </div>
    </body>
    </html>
    
    
    

     

     

     

    Here's the Form code if needed

     

    
    <?php
    include("states.inc");                             
    ?>
    <style type="text/css">
    <!--
    .style1 {color: #FF0000}
    -->
    </style>
    
    
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    
    <tr>
           <td width="35%" valign="top">
             <p><h1>Member Login</h1></p>
             <form action="Login.php?do=login" method="POST">
               <table border="0">
    <?php                                                   
                if (isset($message))
                 echo "<tr><td colspan='2'>$message </td></tr>";
    ?>
               <tr><td align=left>             
                 <p align="right"><b>Username</b>
                 </p>
              </td>
                 <td width="162"><input type="text" name="fusername" 
                          size="20" maxsize="20">
                 </td></tr>
               <tr><td width="78" align="left">
                 <p align="right"><b>Password</b></p>
                 </td>
                 <td><input type="password" name="fpassword" 
                            size="20" maxsize="20"></td></tr>
               <tr><td align="left"> </td>
                 <td align="left"><p><a href="ForgotPassword.php">Forgot Password</a></p>             </td>
               </tr>
               <tr>
                 <td align="left" colspan="2"><input type="submit" name="log" 
                               value="Enter"></td>
               </tr>
             </table>
             </form>     </td>
           
           <td width="65%">
             <p><h1>Register</h1> 
                 </b>
    
    
    
    
    <!-- form for new member to fill in -->
            <form action="Login.php?do=new" method="POST">
              <table border="0">
    <?php
                if (isset($message_new))                    
                   echo "<tr><td colspan='2'>$message_new
                             </td></tr>";
    ?>
            <tr>
              <td align="right"><p><b><span class="style1">*</span>Username</b></p></td>
              <td><input type="text" name="newname" 
                       value="<?php echo @$newname ?>" 
                       size="20" maxlength="20"></td></tr>
               <tr><td align="right"><p><b><span class="style1">*</span>Password</b></p></td>
                   <td><input type="password" name="newpass" 
                              value="<?php echo @$newpass ?>" 
                              size="10" maxlength="8"></td></tr>
               <tr><td align="right"><p><b><span class="style1">*</span>First Name</b></p></td>
                   <td><input type="text" name="firstName" 
                              value="<?php echo @$firstName ?>"
                              size="40" maxlength="40"></td></tr>
               <tr>
                 <td align="right"><p><b><span class="style1">*</span>Last Name</b></p></td>
                 <td><input type="text" name="lastName" 
                              value="<?php echo @$lastName ?>"
                              size="40" maxlength="40"></td></tr>
               <tr>
                 <td align="right"><p><b><span class="style1">*</span>Street</b></p></td>
                 <td><input type="text" name="street" 
                              value="<?php echo @$street ?>"
                              size="55" maxlength="50"></td></tr>
               <tr>
                 <td align="right"><p><b><span class="style1">*</span>City</b></p></td>
                 <td><input type="text" name="city" 
                              value="<?php echo @$city ?>"
                              size="40" maxlength="40"></td></tr>
               <tr>
                 <td align="right"><p><b><span class="style1">*</span>State</b></p></td>
                 <td>    <p>
                    <select name="state"> 
                      <?php
                       $stateName=getStateName();           
                       $stateCode=getStateCode();           
                       for ($n=1;$n<=50;$n++)  
                       {
                          $state=$stateName[$n];
                          $scode=$stateCode[$n];
                          echo "<option value='$scode'";
                          if ($scode== "AL") 
                              echo " selected";
                          echo ">$state\n";
                       }
    ?>
                    </select>
                       <span class="style1">*</span><b>Zip</b>                
                    <input type="text" name="zip" 
                             value="<?php echo @$zip ?>"
                             size="10" maxsize="10">
                 </p></td>
               </tr>
               <tr>
                 <td align=right><p><b><span class="style1">*</span>Phone</b></p></td>
                 <td><input type="test" name="phone" 
                              value="<?php echo @$phone ?>" 
                              size="15" maxlength="20">
    <!--                      <b>Fax</b>
                       <input type="text" name="fax" 
                            value="<?php echo @$fax ?>"
                            size="15" maxlength="20"></td></tr>
    -->
               <tr>
                 <td align=right><p><b><span class="style1">*</span>Email</b></p></td>
                 <td><input type="test" name="email" 
                            value="<?php echo @$email ?>"
                            size="55" maxlength="67"></td></tr>
    
               <tr>
                 <td colspan="2"> <p><b><span class="style1">*</span></b><span class="style1"> required</span> </p>
                   <p>
                        <input type="submit" 
                              value="Become a Member">
                 </p></td></tr>
             </table>
            </form>
           </td>
      </tr>
    </table>
    
    
    

     

  4. Hi. I have a registration script that allows someon to register to my site. After the register they are taken to a login script which consists of a username and password field.

     

    Simple enough.

     

    Here's the weird thing. They can login just fine. But only once!?! The next time they try and login in it fails to execute the query.

     

    Does this sound familiar to anyone?

  5. Hi. I have this database that is sorted in the order that I put the data in. I want it in reverse order by the $row_WADAalbums['Year'] column. I've tried to use the sort function but I really don't know how and failed miserably. By the way, this code was generated by WA DataAssist, that's why there's a lot of it (damn code generators). Thanks in advance for your help.

     

    <?php require_once('db.php'); ?>
    <?php
    $currentPage = $_SERVER["PHP_SELF"];
    ?>
    <?php
    if (!session_id()) session_start();
    if (isset($_SESSION["albums_Results_QueryString"]) && ($_SESSION["albums_Results_QueryString"] != "") && !isset($_SERVER["QUERY_STRING"]) ){
    header("Location: albums_Results.php?".str_replace("&totalRows_","&old_totalRows_",$_SESSION["albums_Results_QueryString"]));
    }
    else{$_SESSION["albums_Results_QueryString"] = isset($_SERVER["QUERY_STRING"])?$_SERVER["QUERY_STRING"]:"";
    }
    ?>
    
    
    <?php
    $maxRows_WADAalbums = 1000;
    $pageNum_WADAalbums = 0;
    if (isset($_GET['pageNum_WADAalbums'])) {
      $pageNum_WADAalbums = $_GET['pageNum_WADAalbums'];
    }
    $startRow_WADAalbums = $pageNum_WADAalbums * $maxRows_WADAalbums;
    
    mysql_select_db($database_disc, $disc);
    $query_WADAalbums = "SELECT * FROM albums";
    $query_limit_WADAalbums = sprintf("%s LIMIT %d, %d", $query_WADAalbums, $startRow_WADAalbums, $maxRows_WADAalbums);
    $WADAalbums = mysql_query($query_limit_WADAalbums, $disc) or die(mysql_error());
    $row_WADAalbums = mysql_fetch_assoc($WADAalbums);
    
    if (isset($_GET['totalRows_WADAalbums'])) {
      $totalRows_WADAalbums = $_GET['totalRows_WADAalbums'];
    } else {
      $all_WADAalbums = mysql_query($query_WADAalbums);
      $totalRows_WADAalbums = mysql_num_rows($all_WADAalbums);
    }
    $totalPages_WADAalbums = ceil($totalRows_WADAalbums/$maxRows_WADAalbums)-1;
    
    
    ?>
    
    
    <?php
    $queryString_WADAalbums = "";
    if (!empty($_SERVER['QUERY_STRING'])) {
      $params = explode("&", $_SERVER['QUERY_STRING']);
      $newParams = array();
      foreach ($params as $param) {
        if (stristr($param, "pageNum_WADAalbums") == false && 
            stristr($param, "totalRows_WADAalbums") == false) {
          array_push($newParams, $param);
        }
      }
      if (count($newParams) != 0) {
        $queryString_WADAalbums = "&" . htmlentities(implode("&", $newParams));
      }
    }
    $queryString_WADAalbums = sprintf("&totalRows_WADAalbums=%d%s", $totalRows_WADAalbums, $queryString_WADAalbums);
    ?>
    <?php
    //WA AltClass Iterator
    class WA_AltClassIterator     {
      var $DisplayIndex;
      var $DisplayArray;
      
      function WA_AltClassIterator($theDisplayArray = array(1)) {
        $this->ClassCounter = 0;
        $this->ClassArray   = $theDisplayArray;
      }
      
      function getClass($incrementClass)  {
        if (sizeof($this->ClassArray) == 0) return "";
      	if ($incrementClass) {
          if ($this->ClassCounter >= sizeof($this->ClassArray)) $this->ClassCounter = 0;
          $this->ClassCounter++;
        }
        if ($this->ClassCounter > 0)
          return $this->ClassArray[$this->ClassCounter-1];
        else
          return $this->ClassArray[0];
      }
    }
    ?><?php
    //WA Alternating Class
    $WARRT_AltClass1 = new WA_AltClassIterator(explode("|", "WADAResultsRowDark|"));
    ?>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Results albums</title>
    <link href="WA_DataAssist/styles/Modular_Slate.css" rel="stylesheet" type="text/css" />
    <link href="WA_DataAssist/styles/Arial.css" rel="stylesheet" type="text/css" />
    </head>
    
    <body>
    
    
    
    <div class="WADAResultsContainer">
      <div class="WADAResultsHeader">
        <div class="WADAHeaderText">  Discography</div>
    
      <?php if ($totalRows_WADAalbums > 0) { // Show if recordset not empty ?>
      <div class="WADAResults">
        <div class="WADAResultsNavigation">
          <div class="WADAResultsCount">Records <?php echo ($startRow_WADAalbums + 1) ?> to <?php echo min($startRow_WADAalbums + $maxRows_WADAalbums, $totalRows_WADAalbums) ?> of <?php echo $totalRows_WADAalbums ?></div>
          <div class="WADAResultsNavTop">
            
          </div>
          
        <table class="WADAResultsTable" border="0" cellpadding="0" cellspacing="0">
          <tr>
      <th class="WADAResultsTableHeader">Cover:</th>
      <th width="40" class="WADAResultsTableHeader">Title:</th>
    
    
            <th width="30" class="WADAResultsTableHeader">Year Released:</th>
            <th width="30" class="WADAResultsTableHeader">Chart Position:</th>
    
            <th width="30" class="WADAResultsTableHeader">Type:</th>
            <th width="30" class="WADAResultsTableHeader">Formats:</th>
            <th width="30" class="WADAResultsTableHeader">Buy Now:</th>
          </tr>
          <?php do { ?>
          <tr class="<?php echo $WARRT_AltClass1->getClass(true); ?>">
    
            <td class="WADAResultsTableCell"><a href="albums_Detail.php?ID=<?php echo(rawurlencode($row_WADAalbums['ID'])); ?>" ><?php echo($row_WADAalbums['sCover']); ?></a></td>
            <td class="WADAResultsTableCell"><a href="albums_Detail.php?ID=<?php echo(rawurlencode($row_WADAalbums['ID'])); ?>" ><?php echo($row_WADAalbums['Title']); ?></a></td>
           
        <td class="WADAResultsTableCell"><?php echo($row_WADAalbums['Year']); ?></td>
            <td class="WADAResultsTableCell"><?php echo($row_WADAalbums['Chart']); ?></td>
    
            <td class="WADAResultsTableCell"><?php echo($row_WADAalbums['Type']); ?></td>
            <td class="WADAResultsTableCell"><?php echo($row_WADAalbums['Formats']); ?></td>
            <td class="WADAResultsTableCell"><?php echo($row_WADAalbums['Buy']); ?></td>
          </tr>
          <?php } while ($row_WADAalbums = mysql_fetch_assoc($WADAalbums)); ?>
        </table>
        <div class="WADAResultsNavigation">
          <div class="WADAResultsCount">Records <?php echo ($startRow_WADAalbums + 1) ?> to <?php echo min($startRow_WADAalbums + $maxRows_WADAalbums, $totalRows_WADAalbums) ?> of <?php echo $totalRows_WADAalbums ?></div>
    
        </div>
      </div>
      <?php } // Show if recordset not empty ?> <?php if ($totalRows_WADAalbums == 0) { // Show if recordset empty ?>
    
    <?php } // Show if recordset empty ?> </div>
    </body>
    </html>
    <?php
    mysql_free_result($WADAalbums);
    ?>
    
    

  6. Hi, I would like to send the viewer to a new page when "if" conditions are met. Here is the last bit of the code. It works fine and the $message is echo'd but I'd like to send them to a new page instead. Is this possible? Thanks.

     

    ... 

                      $message="<b>All Fields are valid. <br> We have recieved your message. Thank you!<b>";

      $name = "$_POST[name]";

      $email = "$_POST";

      $messages = "$_POST[messages]";

      include("db.php");

                      mysql_query("INSERT INTO contacts(name, email, messages) VALUES('$name', '$email', '$messages') ") or die(mysql_error()); 

          }

    echo "$message";

     

    }

     

    ?>

  7. nloding, thanks, this works great! I did try this at first but used b instead of strong and got nothing. I must've missed a ' or something.

     

    I just showed the html code for whatever reason. I said that I wanted to use the php code to make it bold and not the html code. I misstyped "the" as "to" so it wasn't clear. oops!

     

    Thanks. 

  8. Hi, I would like to bold just $gallery_venue in the string below.

     

     

      if ($gallery_content_array[$gallery_catname]) {

        $gallery_content_array[$gallery_catname] .= '' . $gallery_date . '<br>' . $gallery_venue . '<br>' . $gallery_address .'<br>' . $gallery_city . ', ' . $gallery_state . '<br>' . $gallery_phone . '<br>' . $gallery_url . '<br>' . $gallery_description . '<br><br>';

     

    FYI, I display the above code with this code wherein the $name is bold. Is it possible to just bold $gallery_venue  from within to string at the top without doing anything to the code below? 

     

    foreach ($gallery_content_array as $name=>$content) {

      echo "<b>$name</b>";

      echo "<br><br>\n";

      echo $content;

      echo "<br><br>\n";

     

    }

     

     

    Thanks.

  9. Hello, I need help with formatting the date in a string.

     

    First of all I have this. As you can see, the Date is pulled from mysql.

     

    foreach ($galleries as $gallery) {

      $gallery_id = $gallery['ID'];

      $gallery_catid = $gallery['CatID'];

      $gallery_catname = $gallery['CatName'];

      $gallery_catsubof = $gallery['CatSubOf'];

      $gallery_title = $gallery['Title'];

      $gallery_date = $gallery['Date'];

    etc...

     

    This string pulls from the DB and is the output.

     

      if ($gallery_content_array[$gallery_catname]) {

        $gallery_content_array[$gallery_catname] .= '' . $gallery_date . '<br>' . $gallery_venue . '<br>' . $gallery_address .'<br>' . $gallery_city . ', ' . $gallery_state . '<br>' . $gallery_phone . '<br>' . $gallery_url . '<br><br>';

     

     

    It works fine except that the date reads like this:

     

    2007-03-05 21:00:00

    The Palace

    1234 5th street

    Culver City, CA

    310-555-1212

     

    I want the date to read like this, " 03-05-2007, 9:00PM"

     

    I know that I need to add this somewhere (F j, Y, g:i) but I don't know where.

     

    Please help. Thanks

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