Jump to content

steve m

Members
  • Posts

    50
  • Joined

  • Last visited

    Never

Posts posted by steve m

  1. I need help.  I can't seem to figure this out.  I made a form where when submitted, it will email me and two others to notify us that someone is requesting some information.  Well, when somebody tries to submit the form, we get an email from our web host say that the mail was undeliverable - "BAD_HEADER: Improper use of control character (char 0D hex): From: some_email_adress@example.com\r\n".  I can't for the life of me figure out why this is happening.  I've looked at the code and it seems to look all right.  Is there something wrong in the code? 

    <?php
    $To = preg_replace("/\r/", "", $_POST['email']);
    $To = preg_replace("/\n/", "", $_POST['email']);
    
    $headers = "From: $To\r\n";
    $headers .= "Reply-To: $To\r\n";
    $headers.= "Return-Path: info@rcubed.com\r\n";
    $headers .= "CC: $rmail_2, $rmail_3\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1";
    
    mail($rmail_1, $Subject, $Message, $headers);
    ?>
    

  2. Hi All,

    I just bought a new laptop and it has Windows Vista Home Premium.  I'm new to installing PHP, MySQL, and Apache, so I was wondering; can PHP, MySQL, and Apache work on Vista?  I was able to load Apache 2.2.3 on there and it seems to work.  It's when I try to install PHP 4.4.3  I try to start the Apache server and it comes up with an error "can't load module "C:/php/sapi/php4apache.dll".  I've also tried using php4appache2.dll but no success.  So I'm not sure if I need to be using a particular version of these programs.  Do I need to use a particular version?

     

  3. Hello,

     

    I am kind of new to regular expressions and I've been trying to get this script to work, but it won't.  I can't figure out why it doesn't work.  This is just a test script, but I want the preg-match() to find "\n".  The \n is posted through a form, and it seem like the preg_match() function is not reading the \ before the n, because it always comes up false.  Am I doing something wrong here?  I've tried several different ways to the pattern and nothing is working for me.

     

    <?php
    $strip_text = stripslashes($_POST["preg_text"]);
    
    if(preg_match("/(n)/i", $strip_text))
    {
    	echo "It matched";
    }
    
    else
    {
    	echo "Did not Match";
    }	
    ?>
    

  4. Hello,

     

    I am having a problem trying to use the preg_replace() function.  I have a form and I want to remove "new line(\n)", tabs(\t), carriage returns(\r) etc.. from the data being submitted, but it doesn't seem to work.

    <?php
    $str = preg_replace("/\n/", '' ", $_POST[email]);
    
    echo $str;
    
    ?>
    

    It doesn't seem to do anything.  For example, if the email field is submitted with test@test.com\n and I print $str, it prints test@test.com\\n.

     

    Can someone please tell me what I am doing wrong?

  5. Hello,

     

    I have a question on how to pass information from a form.  I am building a simple order form for this site.  I am not using a database because the person that this is for doesn't want to use a database.  On the form I built a function to display the different type of products taken from the array.  Each product has a Qty box and when I loop the array I put a counter in it so I can name the Qty, type, and price fields.  Example: qty0, type0, price0 - qty1 etc...

     

     

    <?php
    function ListDonuts()
    {
    
    	$flavors = array(Glazed => "0.76", 
    					 Chocolate => "0.80", 
    					 White . " " . Sprinkles => "1.20", 
    					 Chocolate . " " . Sprinkles => "1.25", 
    					 Red . " " . Velvet => "2.00",
    					 Peanutbutter . " " . Chocolate => "2.50");
    
    		$item_count = count($flavors);
    		echo $item_count;
    		$i = 1;
    		$j = 0;
    		$columns = 2;
    
    			foreach($flavors as $type => $price)
    			{
    
    				if($i == $columns)
    				{
    					$class = "class='form-colb'";
    
    					$i = 1;
    				}
    				else
    				{
    					$class = "class='form-cola'";
    
    					$i++;
    				}
    
    				$showTypes .= "<div $class>
    								<p class='dis-donut-list'>
    									<input class='input-box' type='textbox' name='qty$j' value='$qty' size='1' />
    									<input type='hidden' name='type$j' value='$type' />
    									<input type='hidden' name='price$j' value='$price' />
    									<input type='hidden' name='item_count' value='$item_count' />										
    									$type -- $$price
    								</p>
    							   </div>\n";
    				$j++;
    			}
    
    		return $showTypes;
    }
    ?>
    

     

    All this is fine until I submit the form.  I want to be able to only select the product items that have a quantity in the qty field.  This is where I am coming up blank.  I've tried making the "qty" field an array (qty[]) (this is not in the above function)and then doing a foreach loop to pull the information, but I don't know how to pass the "type" and "price" values to the qty[] array to display it on the confirmation page or to save it to a CSV file.  So that is why I came up with the above function.  I thought I could just name the those fields with the counter and get the info that way, but I want to efficient about that and not have a lot of IF statements depending on how many items are in the array, because that number can change.  Would any body be able to help me with this problem?  Am I making this harder than it really is?  I am totally having a brain freeze!

     

    Thanks!

     

  6. No, I wasn't thinking of a Fuzzy Search.  It just a search in one table and it just splits up the phrases (if any) and searches that one table.  It seems to find the search term in the database regardless if it is typed in caps or not.  The triuble I have is being able to display thr results.  I want the search term to be displayed in bold in the results.  Example: searched for "time".  In the results, I want that term will be in bold, like "times".  That works fine as long as the text case is the same.  "Shoe will show up if it was all caps but it won't be in bold.  I was just wondering if there is a way that the search can show up in bold for example regardless of how the term is typed in?  Not sure if I made any sense here :P.

  7. Hello,

    I am writing this simple MySQL and PHP search and what I want to do is to highlight the search term in the results when they are displayed on the screen.  I am able to get it to work. but the seach term will only be highlighted(Make it Bold) only if it matches exactly to what was typed in the search box.  Is there a way where the search term doesn't have to exactly match in order for it to be highlighted?  Below is the code where I change the the search term into bold to be displayed on the screen.

    <?php
    $result_manufact = str_replace($splitstr, "<span style=\"color: red; font-weight: bold;\">$splitstr</span>", $manufact);
    ?> 
    
    

  8. Hello all,

     

    I am have problems with uploading pictures to this site that I am working on.  I've been testing it on my local machine and it works fine.  The picture is resized and a copy of the picture is saved to the folder that I want it to be saved at.  It even save the correct url to the data base.  When I uploaded the files to this site and tried to run the scripts it doesn't work.  The picture isn't saved and even the file name of the picture isn't saved to the database.  It seems like the file name is not being passed for example... "images/" the file name of the picture is not saved.  I know wit script it works on my local machine, but not from the site where it is to be used.

     

    I've tried several different things as far as how to handle the POST varibles like using $_POST[], $_REQUEST[], but I still can't to get it ti work.  Can anyone tell me what I'm doing wrong?

     

    HTML Form

    <form ENCTYPE="multipart/form-data" name="loadpict" action="write_upload_picts.php" method="post">
    							<p>
    
    								<label for="pict">Picture: </label>
    								<input id="pict" type="file" name="picturl" />
    							</p>
    							<p>
    								<label for="text">Caption: </label>
    								<textarea id="text" name="caption" cols="10" rows="5"></textarea>
    							</p>
    						<input class="formbutton" type="submit" name="submit" value="Save Picture">
    </form>
    

     

    PHP Code:

    <?php
    	list($width,$height)=getimagesize($picturl);
    
    		if(($width > 640) && ($height < $width))
    		{					
    			$newwidth=640;
    			$newheight=($height/$width)*$newwidth;
    
    			//resizeImage($width, $height, $picturl, $newwidth, $newheight);
    
    			// Create an Image from it so we can do the resize
    				$src = imagecreatefromjpeg($picturl);
    
    			// Capture the original size of the uploaded image
    				list($width,$height)=getimagesize($picturl);
    
    				$tmp=imagecreatetruecolor($newwidth,$newheight);
    
    			// this line actually does the image resizing, copying from the original
    			// image into the $tmp image
    				imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); 
    
    			// now write the resized image to disk. I have assumed that you want the
    			// resized, uploaded image file to reside in the ./images subdirectory.
    				$filename = "../images/". $_FILES['picturl']['name'];
    				imagejpeg($tmp,$filename,100);
    
    				imagedestroy($src);
    				imagedestroy($tmp);
    ?>
    
    

  9. Hi,

     

    I'm trying to create a form that list row from a database and when I display the results it puts a checkbox and a text field for quantity.  I am able to create an array from the checkboxes submitted and then I can display or do what ever I need to with that array.  The problem that I'm having is that along with the checkboxes I need to submit the quantities along with it.

     

    First part:

     

    <td width='5%' style='margin-left: 4px; border-bottom: 1px solid #DBDBDB;' height='30'>
    <input type='checkbox' name='row[]' value='$row[man_pn]'>
    </td>
    <td width='60%' style='margin-left: 4px; border-bottom: 1px solid #DBDBDB;' height='30'>
    <p class='itemtitle'>
      $row[item_title]
    </p>
    </td>
    <td width='15%' style='margin-left: 4px; border-bottom: 1px solid #DBDBDB;' height='30'>
    <p class='itemtitle'>
      $row[r3_price]
    </p>
    </td>
    <td width='20%' style='margin-left: 4px; border-bottom: 1px solid #DBDBDB;' height='30'>
    <input type='text' value='1' name='qty' size='3'>
    </td>
    

     

    Second part:

     

    foreach($_POST["row"] as $select_rows)
    {
    $item_query = mysql_query("SELECT * from equipment where man_pn = '$select_rows'") or die("error: " . mysql_error());
    
    while($fetchrows = mysql_fetch_array($item_query))
    {
        echo $fetchrows["item_title"] . " " . $fetchrows["r3_price"] . " " . $_POST["qty"] . "<br>";
    }				
    }
    
    

     

    If you look at the first part I have the checkbox field that becomes the array when submitted.  Is there a way to add the QTY filed with the row[] array?

     

    Thank you in advance

     

  10. Hi All,

    I'm trying to write a script where I can change for example, multiple prices from a dynamically created form.  I first have a form where it get info from the database and displays it in a list.  What I did was where the field that I want to be able to change I made it a text box.  This works fine.  The problem that I'm having is the POST.  In the text box value I made it an array, so when I submit the form it shows me all of the values for that text box if I use a foreach loop.

    [code]<? php echo "<input type=\"text\" value=\"$cst\" name=\"cst[]\" size=\"5\">"; ?>[/code]

    $cst is the cost field.

    What I want to do is to go thru that array and update the records, but I can't seem to figure out on how to associate the record Id(inv_id) to the $cst when submitting the form.  I need to query the database to look up the inv_id to update the cost column.

    Does anyone have any ideas on how to solve this dilemma?
×
×
  • 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.