Jump to content

Paul_Bunyan

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Posts posted by Paul_Bunyan

  1. Hi all.  I'm maintaining a database of engineers with some php pages linked to an Oracle database.  I would like to be able to maintain a record of how long it has been since a user has last logged in to update their profile and if it has been a year automatically send them a notification.  I'm not sure how to implement a timer that would check each users profiles.  I was just hoping that someone could suggest an approach as I haven't as of yet figured out how to tackle this.  Thanks in advance for any ideas.

  2. I'm VERY curious as to why you're using $HTTP_POST_VARS instead of the better superglobal, $_POST. >_>

     

    I'm pretty new to PHP and I took over a project for someone.  I modelled all my pages after his and it was just how he did things.  I'll look into using $_POST instead.  Thanks for the heads up.

     

    This is most likely caused by the fact that IE will not send a value for an input type=submit if ENTER is pressed instead of clicking it. Test the form with pressing ENTER and clicking and see if there is a difference in the way the code responds.

     

    Ah ok, thank you.

     

  3. Hi al.  I'm encountering a weird error where my form doesn't get submitted unless I click it 2 times.  I don't mean double click, but only after I have submitted it twice.  I just wanted to see if someone could take a look at my code to see if there is something obvious that I am overlooking.  Thanks for any insight. :)  **EDIT:  I don't know where those boxes came from.  I can't see how to remove em...

     

    <?php
    // connection statement
    require_once('../Connections/pubs_db.php');
    
    // additional functions
    require_once('../includes/functions.inc.php');
    require_once('../php/functions.php');
    
    // build the form action
    $editFormAction = $HTTP_SERVER_VARS['PHP_SELF'] . (isset($HTTP_SERVER_VARS['QUERY_STRING']) ? "?" . $HTTP_SERVER_VARS['QUERY_STRING'] : "");
    
    if (isset($HTTP_POST_VARS["Submit"])) 
    {
    if($HTTP_POST_VARS['contact_email'] != "")
    {
    	$traceMsg = "email is not blank";
    
       		// check if the user id and password combination exist in database
       		$sql = "SELECT username, password 
               		FROM user_directory
               		WHERE contact_email=".squote_string(parse_string($HTTP_POST_VARS['contact_email']));
    	   		
    	$result = $pubs_db->Execute($sql) or die('Query failed. ' .$pubs_db->ErrorMsg().$sql);
    
       		$commit = $pubs_db->Execute("commit") or die($pubs_db->ErrorMsg());
       
       		$totalRows = $result->RecordCount();
      
       		if ($totalRows == 1) 
       		{
    
      		//set subject
      		$subject = "Geotech Account Information";
    
    		//set recipient
    		$recip = $HTTP_POST_VARS['contact_email'];
    
          		//email username and password
    		$headers = "From: wo@email.com";
    		$body = "This is your account information for your Geotech skills account:\n Username: ".$result->Fields('username')."\n Password: ".$result->Fields('password')."\n\ Josh Morsel Buns";
    
    		# The format of the mail() function:
    		#mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])
    		if(mail($recip, $subject, $body, $headers ) == false)
    		{
    			$errorMessage = 'Email failed';
    		}
    		else
    		{
    			// after login we move to the index page
      			$insertGoTo = "index.php";
    
    			KT_redir($insertGoTo);
    		}
          
       		} 
       		else 
       		{
          		$errorMessage = 'Email not on file.';
       		}
    
    }
    else 
       	{
          		$errorMessage = 'You must enter your email.';
       	}
    }
    
    ?>
    <!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=iso-8859-1" />
    <title>Untitled Document</title>
    <link href="../mainstyl.css" rel="stylesheet" type="text/css" />
    <link href="../mainstyl.css" rel="stylesheet" type="text/css" />
    
    </div>
    </head>
    <style type="text/css">
    <!--
    .style4 {font-size: 24px}
    -->
    </style>
    </head>
    
    <body>
    <p align="center" class="xsmallnavybold"><br />
      <br />
      <span class="navybold style4">Username/Password retrieval :</span></p>
      <p align="center" class="maroonitalicbold">Directions: Please enter the contact email that you have for this Geotech skills account. Your username and password will be emailed to you.</p>
      </div>
    <?php
    if ($errorMessage != '') 
    {
    echo $errorMessage;
    }
    ?>
    </p>
        <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data">
      <table width="400" border="1" align="center" cellpadding="2" cellspacing="2" class="tbl_greenbordersolid">
    <tr>
    <td width="150" class="largebold">Contact Email:</td>
    <td><input name="contact_email" type="text" id="contact_email" value="<?php echo $HTTP_POST_VARS['contact_email']; ?>" /></td>
    </tr>
    
    <tr>
    <td width="150"> </td>
    <td><input type="submit" name="Submit" value="Submit"></td>
    </tr>
    </table>
    </form>
    
    </body>
    </html>
    

  4. I just wanted to say thanks for all the help.  It turns out that even though Dreamweaver was telling me that I had changed the permissions on my folder, on my web server it was not changing.  I had to SSH in and chmod it.  That, and I had to use the absolute path for my destination.

     

    Thank you!  :)

  5. Ok, so I found my temp directory for files and it's permissions are already set to 775.

     

    I'm still getting this error:

     

    Warning: move_uploaded_file(images/1215800976.jpg) [function.move-uploaded-file]: failed to open stream:

     

    &

     

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/fsfiles/ref/infocenter/fsweb/files/phpKk35Ea' to 'images/1215800976.jpg'

  6. Hello.  I am having problems uploading photos to my web server.  I have set the permissions on the file "images" to 777 via dreamweaver but when I submit the upload I still get the error message:

     

    Warning: copy(images/1215797607.jpg) [function.copy]: failed to open stream: Permission denied

     

    I am using code found on this page (http://www.reconn.us/content/view/30/51/):

    I thought it was a permissions error at first but now I am wondering if there is something I may have overlooked in the code.  Thanks in advance.

    <?php
    
    //define a maxim size for the uploaded images in Kb 
    define ("MAX_SIZE","100"); 
    //This function reads the extension of the file. It is used to determine if the file  is an image by checking the extension.
    function getExtension($str) 
    {   
    	$i = strrpos($str,".");         
    if (!$i) { return ""; }         
    $l = strlen($str) - $i;         
    $ext = substr($str,$i+1,$l);         
    return $ext; 
    }
    
    //This variable is used as a flag. The value is initialized with 0 (meaning no error  found)  
    //and it will be changed to 1 if an errro occures.  
    //If the error occures the file will not be uploaded. 
    
    $errors=0;
    
    //checks if the form has been submitted 
    
    if(isset($_POST['Submit']))  
    { 	
    //reads the name of the file the user submitted for uploading 	
    $image=$_FILES['image']['name']; 	
    
    //if it is not empty 	
    
    if ($image)
    { 	
    	//get the original name of the file from the clients machine 		
    	$filename = stripslashes($_FILES['image']['name']); 	
    
    	//get the extension of the file in a lower case format  		
    	$extension = getExtension($filename); 		
    	$extension = strtolower($extension); 	
    
    	//if it is not a known extension, we will suppose it is an error and will not  upload the file,  	
    	//otherwise we will do more tests 
    	if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))  		
    	{		
    		//print error message 			
    		echo '<h1>Unknown extension!</h1>'; 			
    		$errors=1; 		
    	} 		
    	else 		
    	{
    		//get the size of the image in bytes 
    		//$_FILES['image']['tmp_name'] is the temporary filename of the file 
    		//in which the uploaded file was stored on the server 
    		$size=filesize($_FILES['image']['tmp_name']);
    
    		//compare the size with the maxim size we defined and print error if bigger
    		if ($size > MAX_SIZE*1024)
    		{	
    			echo '<h1>You have exceeded the size limit!</h1>';	
    			$errors=1;
    		}
    
    		//we will give an unique name, for example the time in unix time format
    		$image_name=time().'.'.$extension;
    
    		//the new name will be containing the full path where will be stored (images folder)
    		$newname="images/".$image_name;
    
    		//we verify if the image has been uploaded, and print error instead
    		$copied = copy($_FILES['image']['tmp_name'], $newname);
    
    		if (!$copied) 
    		{	
    			echo '<h1>Copy unsuccessfull!</h1>';	
    			$errors=1;
    		}
    	}
    }
    }
    
    		//If no errors registred, print the success message 
    if(isset($_POST['Submit']) && !$errors)  
    { 	
    			echo "<h1>File Uploaded Successfully! Try again!</h1>"; 
    } ?> 
    
    <!--next comes the form, you must set the enctype to "multipart/frm-data" and use an input type "file" --> <form name="newad" method="post" enctype="multipart/form-data"  action=""> <table> 	<tr><td><input type="file" name="image"></td></tr> 	<tr><td><input name="Submit" type="submit" value="Upload image"></td></tr> </table>	 </form>   
    

  7. Here is the source that is generated:

    <tr>
        <th align="left" valign="top" scope="row">Total Jumps:  </th>
        <td align="left" valign="top">
    <select name="total_jumps" id="total_jumps">
         <option value="NA" >Not applicable.</option>
          <option value="19" >< 20</option>
          <option value="21" >20 to 49</option>
          <option value="51" >50 to 99</option>
      <option value="101" >100 to 149</option>
      <option value="151" >150 to 199</option>
      <option value="201" >200 to 249</option>
      <option value="251"  >250 to 299</option>
      <option value="300" >> 299</option>
      </select>	
      </td>
        <td align="left" valign="top">*ND</td>
      </tr>
    

  8. What do you mean by "it does not work"?  Does it error you?  Does it just not select the proper one?

     

    Ah, sorry I wasn't specific.  It doesn't select the correct option.  It always selects, "Not Applicable."

     

    .

    i have fought with this in the past too.

     

    try changing

    echo "selected"
    

     

    to

    
    echo 'selected="selected"';
    
    

     

    sounds stupid, but i've had that exact issue break select boxes on me.

     

    I tried your solution mbeals, but I still can't get the right option to be selected.  I also tried all of the variations given by Jabop.

     

    Thanks for the help so far

  9. Hello.  I am attempting to make an update page where an admin can modify existing records. 

    I am running into a problem when I create my drop down lists with php and I can't seem to find the error that I am making or a thread with the same problem.

     

    I am reading from an Oracle database and grabbing my record with the following code:

     

    <?php
    $select_doc = "SELECT total_jumps FROM mars_reports WHERE rec_id=".$rec_id;
    $doc = $pubs_db->Execute($select_doc) or die($pubs_db->ErrorMsg());
    $com = $pubs_db->Execute("commit") or die($pubs_db->ErrorMsg());
    ?>
    

     

    As a test I have been echoing out the results to make sure that I am reading successfully:

     

    <?php 
    
    echo $doc->Fields('total_jumps');
      
    ?>

     

    I get the expected value.  However, when I try to create my dropdown list in my form with the correct value selected by default, it does not work.  Here is the code I use w/in my form:

    <tr>
        <th align="left" valign="top" scope="row">Total Jumps:  </th>
        <td align="left" valign="top">
      <select name="total_jumps" id="total_jumps">
      <option value="NA" <?php if($doc->Fields('total_jumps')=="NA") echo "selected"; ?>>Not applicable.</option>
      <option value="19" <?php if($doc->Fields('total_jumps')=="19") echo "selected"; ?>>< 20</option>
      <option value="21" <?php if($doc->Fields('total_jumps')=="21") echo "selected"; ?>>20 to 49</option>
      <option value="51" <?php if($doc->Fields('total_jumps')=="51") echo "selected"; ?>>50 to 99</option>
      <option value="101" <?php if($doc->Fields('total_jumps')=="101") echo "selected"; ?>>100 to 149</option>
      <option value="151" <?php if($doc->Fields('total_jumps')=="151") echo "selected"; ?>>150 to 199</option>
      <option value="201" <?php if($doc->Fields('total_jumps')=="201") echo "selected"; ?>>200 to 249</option>
      <option value="251" <?php if($doc->Fields('total_jumps')=="251") echo "selected"; ?> >250 to 299</option>
      <option value="300" <?php if($doc->Fields('total_jumps')== "300") echo "selected"; ?>>> 299</option>
      </select>	
      </td>
        <td align="left" valign="top">*ND</td>
      </tr>

     

     

    Thank you for any insight you may have into my problem.

     

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