Jump to content

tqla

Members
  • Posts

    366
  • Joined

  • Last visited

Posts posted by tqla

  1. Hello. My code displays error messages by field name but I would like then to display in a more descriptive name. I have created the $labels = array but I can't figure out how to use it. The errors are still showing the field name.

     

    Here is the pertinent part of my script. Please help. Thanks!

     

    <?php require_once('Connections/Auth.php'); ?>
    <?php
      session_start();  
    
       case "new":   
       
         /* set up array containing all the fields */
      $labels = array ( "newname" => "User Name",
                        "newpass" => "Password",
                        "firstname" => "First Name",
                        "lastname" => "Last Name",
                        "company" => "Company",
                        "phone" => "Phone",
                        "email" => "Email",
                        "zip" => "Zip Code",		
    				);
       
                                                    
    
      /* Check for blanks */                           
         foreach($_POST as $field => $value)               
         {
            if ($field != "fax")                           
            {
               if ($value == "")                           
               {
                  $blanks[] = $field;
               }
            }
         }
         if(isset($blanks))                               
         {
            $message_new = "<b>The following fields are blank.</b><br><br>  
                Please enter the required information:  ";
            foreach($blanks as $value)
            {
               $message_new .= "<BR><b>$value</b>";
            }
            extract($_POST);
            include("formSRL.inc");
            exit();
         }
    
        /* Validate data */
         foreach($_POST as $field => $value)              
         {
            if(!empty($value))                            
            {
               if(eregi("newname",$field) and
                  !eregi("newpass",$field))
               {
                  if (!ereg("^[A-Za-z' -]{1,50}$",$value)) 
                  {
                     $errors[]="$value is not a valid name."; 
                  }
               }
               if(eregi("firstName",$field) or eregi("lastName",$field) or eregi("company",$field) or eregi("title",$field))
               {
                  if(!ereg("^[A-Za-z0-9.,'& -]{1,50}$",$value))
                  {
                     $errors[] = "$value is not a valid.";
                  }
               }
               if(eregi("email",$field))
               {
                  if(!ereg("^.+@.+\\..+$",$value))
                  {
                     $errors[] = "$value is not a valid 
                                  email address.";
                  }
               }
               if(eregi("phone",$field))
               {
                  if(!ereg("^[0-9)(xX -]{7,20}$",$value))
                  {
                     $errors[] = "$value is not a valid  
                                  phone number. ";
                  }
               }
            } // end if empty                             
         } // end foreach
         if(@is_array($errors))                           
         {
            $message_new = "";
            foreach($errors as $value)
            {
              $message_new .= $value." Please try 
                                       again<br />";
            }
            extract($_POST);
            include("formSRL.inc");
            exit();
         } 
    
          /* clean data */
    $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."); 
    
         foreach($_POST as $field => $value)              
         {
            if($field != "Button" and $field != "do")
            {
               if($field == "password")
               {
                  $password = strip_tags(trim($value));
               }
               else
               {
                  $fields[]=$field;
                  $value = str_replace("&", "and", strip_tags(trim($value)));
                  $values[] = mysql_real_escape_string($connection,$value);
                  $$field = $value;                 
               }
            }
         }
    
    
                                                      
          /* check to see if login name already exists */
    
          $sql = "SELECT loginName FROM Member 
                    WHERE loginName='$newname'";
          $result = mysql_query($sql)
                    or die(mysql_error());
          $num = mysql_numrows($result);
          if ($num > 0)                                      
          {
            unset($_GET['do']);
            $message_new = "<p><font color=#ff0000>$newname already used. Select another
                             Username.</font></p>";
            include("formSRL.inc");
            exit();
          }
          else                                               
          { 
    ?>
    

  2. Hello.

     

    I have a link that links to a file. One can click on that link and see the file but only if they are logged in. If they are not logged in they are redirected to a login page. Once they successfully log in they are automatically taken to the file. This works fine.

     

    This is what's in the address bar during this process, it automatically shows the folder and php page where the file is located:

     

    http://ufjfurjtrigj.com/resource_center/insight/MRLlogin.php?accesscheck=%2Fresource_center%2Fpdfs%2FTechnology_Adoption.php

     

    On this same login page I have a link to a signup page that they can use if they don't already have a username and password.

     

    What I want to do is carry the same URL to the registration page, or in other words, register the "accesscheck" variable so that after they successfully register they will automatically be taken to the file too.

     

    How can I register this variable when the user clicks on the signup page link?

     

    After I register the variable I will use

    header("Location: " . $accesscheck);   

    to get to the page. (I think)

     

    Ya know what I mean? Thanks.

     

  3. I am stuck in that this menu is to be a php include into all of the other pages on the site (I change the name to mainmenu.php) Funny thing, the dropdown works in ie7 on it's own until I include it and then no worky.

     

    Thank you both. I'm encouraged to continue. Come to think of it, I can ace the second and third dropdowns, they were just icing and not really necessary.

     

    Yes, I know about the pitfalls a javascript. Bummer there too.

     

    dbrimlow, I am interested to see what you come up with.

     

    Thanks again.

     

     

  4. Hello.

     

    I am using the following horizontal menu with dropdown and it works fine in FireFox but the dropdown doesn't work in IE (no surprise there). Can someone help me get this to work in IE7 too?

     

    Thanks.

     

    Menu

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Untitled</title>
    <link rel="stylesheet" type="text/css" href="css/menu_style.css" />
    </head>
    <body>
    
    <DIV ID="Container">
    <ul id="navigation-1">
    	<li><a href="#" title="Home">Home</a>
    		<ul class="navigation-2">
    			<li><a href="#" title="Electric Guitars">Electric Guitars</a></li>
    		</ul>
    	</li>
    	<li><a href="#" title="Products">Products</a>
    		<ul class="navigation-2">
    			<li><a href="#" title="Electric Guitars">Electric Guitars</a></li>
    			<li><a href="#" title="Acoustic Guitars">Acoustic Guitars <span>»</span></a>
    				<ul class="navigation-3">
    					<li><a href="#" title="Six String">Six String</a></li>
    					<li><a href="#" title="Twelve String">Twelve String</a></li>
    				</ul>
    			</li>
    			<li><a href="#" title="Bass Guitars">Bass Guitars</a></li>
    			<li><a href="#" title="Accessories">Accessories <span>»</span></a>
    				<ul class="navigation-3">
    					<li><a href="#" title="Guitar Stands">Guitar Stands</a></li>
    					<li><a href="#" title="Strings">Strings</a></li>
    					<li><a href="#" title="Tuners">Tuners</a></li>
    					<li><a href="#" title="Plectrums">Plectrums</a></li>
    					<li><a href="#" title="Capos">Capos</a></li>
    					<li><a href="#" title="Cases">Cases</a></li>
    					<li><a href="#" title="Straps">Straps</a></li>
    				</ul>
    			</li>
    		</ul>
    	</li>
    	<li><a href="#" title="Your Account">Your Account</a>
    		<ul class="navigation-2">
    			<li><a href="#" title="Log In">Log In</a></li>
    			<li><a href="#" title="Register">Register</a></li>
    		</ul>
    	</li>
    	<li><a href="#" title="Help">Help</a>
    		<ul class="navigation-2">
    			<li><a href="#" title="FAQs">FAQs</a></li>
    			<li><a href="#" title="Forum">Forum</a></li>
    			<li><a href="#" title="Contact Us">Contact Us</a></li>
    		</ul>
    	</li>
    	<li><a href="#" title="Blah">Links</a>
    		<ul class="navigation-2">
    			<li><a href="#" title="Taylor Guitars">Taylor Guitars</a></li>
    			<li><a href="#" title="AER Amplifiers">AER Amplifiers</a></li>
    			<li><a href="#" title="Shure">Shure</a></li>
    			<li><a href="#" title="International">International <span>»</span></a>
    				<ul class="navigation-3">
    					<li><a href="#" title="Musican's Friend">Musican's Friend</a></li>
    					<li><a href="#" title="Thomann Music">Thomann Music</a></li>
    					<li><a href="#" title="Turnkey">Turnkey</a></li>
    				</ul>
    			</li>
    		</ul>
    	</li>
    </ul>
    </DIV>
    
    </body>
    </html>
    

     

    CSS

    #Container {
    position:absolute;
    left:70px;
    top:151px;
    width:686px;
    height:37px;
    }
    
    
    
    h1
    { width:686px; margin:1px; color:#4C1B1B; font:helvetica; font-size:24pt; overflow:hidden; padding:80px 0 0; vertical-align:middle; text-align:right; }
    p	{ margin:0; padding:1.2em; }
    p a:link,
    p a:visited,
    p a:hover,
    p a:active
    { font-weight:bold; color:#b9121b; }
    
    ul#navigation-1
    { margin:0; padding:1px 0; list-style:none; width:100%; height:21px; border-top:0px solid #b9121b; border-bottom:0px solid #b9121b; font:normal 8pt verdana, arial, helvetica;}
    ul#navigation-1 li
    { margin:0; padding:0; display:block; float:left; position:relative; width:100px; }
    ul#navigation-1 li a:link,
    ul#navigation-1 li a:visited
    { padding:10px 0; display:block; text-align:center; text-decoration:none; background:#b9121b; color:#ffffff; width:100px; height:37px; }
    ul#navigation-1 li:hover a,
    ul#navigation-1 li a:hover,
    ul#navigation-1 li a:active
    { padding:10px 0; display:block; text-align:center; text-decoration:none; background:#ec454e; color:#ffffff; width:100px; height:13px; border-left:0px solid #ffffff; border-right:0px solid #ffffff; }
    
    ul#navigation-1 li ul.navigation-2
    { margin:0; padding:16px 1px 0; list-style:none; display:none; background:; width:100px; position:absolute; top:21px; left:-1px; border:0px solid #b9121b; border-top:none; }
    ul#navigation-1 li:hover ul.navigation-2
    { display:block; }
    ul#navigation-1 li ul.navigation-2 li
    { width:100px; clear:left; width:100px; }
    
    ul#navigation-1 li ul.navigation-2 li a:link,
    ul#navigation-1 li ul.navigation-2 li a:visited
    { clear:left; background:#b9121b; padding:4px 0; width:100px; border:none; border-bottom:0px solid #ffffff; position:relative; z-index:1000; }
    ul#navigation-1 li ul.navigation-2 li:hover a,
    ul#navigation-1 li ul.navigation-2 li a:active,
    ul#navigation-1 li ul.navigation-2 li a:hover
    { clear:left; background:#ec454e; padding:4px 0; width:100px; border:none; border-bottom:0px solid #ffffff; position:relative; z-index:1000; }
    
    ul#navigation-1 li ul.navigation-2 li ul.navigation-3
    { display:none; margin:0; padding:0; list-style:none; position:absolute; left:100px; top:-2px; padding:1px 1px 0 1px; border:0px solid #b9121b; border-left:0px solid #b9121b; background:; z-index:900; }
    ul#navigation-1 li ul.navigation-2 li:hover ul.navigation-3
    { display:block; }
    ul#navigation-1 li ul.navigation-2 li ul.navigation-3 li a:link,
    ul#navigation-1 li ul.navigation-2 li ul.navigation-3 li a:visited
    { background:#b9121b; }
    ul#navigation-1 li ul.navigation-2 li ul.navigation-3 li:hover a,
    ul#navigation-1 li ul.navigation-2 li ul.navigation-3 li a:hover,
    ul#navigation-1 li ul.navigation-2 li ul.navigation-3 li a:active
    { background:#ec454e; }
    ul#navigation-1 li ul.navigation-2 li a span
    { position:absolute; top:0; left:90px; font-size:12pt; color:#fe676f; }
    ul#navigation-1 li ul.navigation-2 li:hover a span,
    ul#navigation-1 li ul.navigation-2 li a:hover span
    { position:absolute; top:0; left:90px; font-size:12pt; color:#ffffff; }
    

  5. Implode! I was thinking about that but had no idea how do properly use it.

     

    Don't see why you would ever want a single field like this want to explain what this is for?

     

    lol, actually this is just an excerpt of the real code. I extracted it so that I can find help here.

     

    Thanks cooldude832, I'll try this now.

  6. Ah ha. Thank you. I see. Okay, I did it but now instead of the 1 DB record showing "RedBlueYellowOrange", four records were created! One for Red, one for Blue, one for Yellow, and one for Orange.  :o  I want 1 record to be created and have "RedBlueYellowOrange" in the "leads" field.  ???

  7. Actually I am querying it. I just left it out in my post. I am using

     

    mysql_query($sql) or die(mysql_error());

     

    The problem is the only the last array item is going into the database.

     

    Just Orange.

     

    I would think that RedBlueYellowOrange would populate the DB.

     

    I don't get it.

  8. Hello, I am using this code to print out an array and it works:

     

    foreach ($leads as $lead){
    	echo $lead;
    	}

     

    I get a list of the $leads array. It looks like this "RedBlueYellowOrange"

     

    Then  I attempt to place that array into my DB like this:

     

    $today = date("Y-m-d");
    $date=time();   
    $sql = "INSERT INTO DB 
    
    (createDate,
    leads
    )
    
    VALUES
    
    ('$today',
    '$lead',
    )";

     

    The problem is that only the last item in the array is placed in the database (Orange).

     

    How do I get them all to go into the DB? What am I doing wrong?

     

     

  9. I use this script to validate phone numbers. It works fine but the client wants to be able to accept a period (.) as well as a dash (-) between numbers. Where do I add the period? Thanks.

     

    /* check phone for invalid format. */
        elseif ($field == "telephone" or
    		$field == "mobile")
        {
          if(!ereg("^[0-9)( -]{7,20}(([xX]|(ext)|(ex))?[ -]?[0-9]{1,7})?$",$value))
          {
               $bad_format[] = $field;
    

     

  10. Is this code applying strip_tags to all $value elements or just the ones that it performed a str_replace on?

     

    $value = str_replace("&", "and", strip_tags(trim($value)));

     

    I'm wondering if I need to add this too right under it to cover the other $value elements:

     

    $value = strip_tags(trim($value));

     

    Or does the first one suffice?  ???

     

    Thank you.

  11. Hello. This is weird and I know it's something simple but I can't figure it out.

     

    Look at the code below. I can see all of the variables from the 'echo' test, but the DB does not get populated. Does the DB part look right? I don't get DB errors so I know that it is connected, and the DB table name is correct.  ???

     

      		/* if data is good */
    
    
    	 $firstName = $_POST['firstName'];
    	 $lastName = $_POST['lastName'];
    	 $title = $_POST['title'];
    	 $company = $_POST['company'];
    	 $street = $_POST['street'];
    	 $city = $_POST['city'];
    	 $state = $_POST['state'];
    	 $zip = $_POST['zip'];
    	 $telephone = $_POST['telephone'];
    	 $email = $_POST['email'];
    	 $annual_revenue = $_POST['annual_revenue'];
    	 $mailboxes = $_POST['mailboxes'];
    	 $email_app = $_POST['email_app']; 
    	 $email_app_other = $_POST['email_app_other']; 
    	 $future_app = $_POST['future_app'];
    	 $future_app_other = $_POST['future_app_other'];
    	 $archiving = $_POST['archiving'];
    	 $email_satisfaction = $_POST['email_satisfaction'];
    	 $interest = $_POST['interest'];
    
    
    /* Test to see if variable took */
    
    echo "$createDate,
    $firstName,
    $lastName,
    $title,
    $company, 
    $street, 
    $city,
    $state, 
    $zip, 
    $telephone, 
    $email,
    $annual_revenue, 
    $mailboxes, 
    $email_app, 
    $email_app_other, 
    $future_app, 
    $future_app_other, 
    $archiving, 
    $email_satisfaction, 
    $interest,
    ";
    
    
    
    
    
    $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."); 
    
          	$today = date("Y-m-d");
      	$date=time();   
    	 $sql = "INSERT INTO survey 
    
    	(createDate,
    	firstName,
    	lastName,
    	title,
    	company,
    	street,
    	city,
    	state,
    	zip,
    	telephone,
    	email,
    	annual_revenue,
    	mailboxes,
    	email_app, 
    	email_app_other, 
    	future_app,
    	future_app_other,
    	archiving,
    	email_satisfaction,
    	interest) 
    
    	VALUES
    
    	('$today',
    	'$firstName',
    	'$lastName',
    	'$title',
    	'$company',
    	'$street',
    	'$city',
    	'$state',
    	'$zip',
    	'$telephone',
    	'$email',
    	'$annual_revenue',
    	'$mailboxes',
    	'$email_app', 
    	'$email_app_other', 
    	'$future_app',
    	'$future_app_other',
    	'$archiving',
    	'$email_satisfaction',
    	'$interest')"; 
    
    
    
    	echo "done"; 
    
    	session_destroy();
    ?>
    

  12. This string works:

    if (isset($blank_array) && $_POST['answer'] == 'No') { ?>

     

    I'd like to add one more item to the ($blank_array) part called $bad_format. It should be of the 'or' type where it checks if any of them are set.

     

    I tried this:

    if (isset($blank_array || $bad_format) && $_POST['answer'] == 'No') { ?>

     

    but I got this error:

    Parse error: syntax error, unexpected T_BOOLEAN_OR, expecting ',' or ')'

     

    So I tried this:

    if (isset($blank_array or $bad_format) && $_POST['answer'] == 'No') { ?>

     

    And got another error.

     

    What am I doing wrong?  ???

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