premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
<?php // changed this to be a better check thata it is not empty if (isset($_POST["email"]) && !empty($_POST["email"])) { $ToEmail = 'emailhere'; $EmailSubject = trim($_POST["subject"]); // \r\n should only be for mail headers. Nothing else. $mailheader = "From: ".$_POST["email"]."\r\n"; $MESSAGE_BODY = trim($_POST["comment"]); // trim any whitespaces there may be in the body mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?> Your Text has been sent. Any replies will go to:<?php echo $_POST["email"]; ?> <?php } else { ?> <form action="test.php" method="post"> <table width="400" border="0" cellspacing="2" cellpadding="0"> <tr> <td width="29%" class="bodytext">Subject:</td> <td width="71%"><input name="subject" type="text" id="name" size="32"></td> </tr> <tr> <td class="bodytext">Message:</td> <td><textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea></td> </tr> <tr> <td class="bodytext">Email address:</td> <td><input name="email" type="text" id="email" size="32"></td> </tr> <tr> <td class="bodytext"> </td> <td align="left" valign="top"><input type="submit" name="Submit" value="Send"></td> </tr> </table> </form> <?php } ?> Made use of trim also removed some \r\n after the subject and body as it is only needed for headers. See if this helps.
-
You are not echoing/printing anything else. It is suppose to not show anything due to that fact.
-
The ~ just states everything in between is part of the regex. The ( ) is the conditional. Inside the [ ] is the characters we want to test. If the item is not a-z it gets replaced the ^ before the a-z indicates not. The + says match 1 (it may be 0) or more characters that are not a-z. If it finds the match then it replaces it. Regex can be complicated and take some time to understand, but is very powerful and useful. EDIT: To any regex experts, if what I have stated is wrong, please correct me I am still learning regex.
-
<?php $header_data[] = "testtest1234_'\""; $header_data[] = "testtest5678-;:[].,<>?_'\"adsf"; $used = 0; for ($x = 0; $x < 2; $x++){ #new code line here# $header_data[$x] = preg_replace('~([^a-z]+)~i',"",$header_data[$x]); #end new code# //$header_data[$x] = trim($header_data[$x], '"'); if($header_data[$x] !== ""){ $used++; } } echo "<pre>"; var_dump($header_data); echo $used; die(); ?> Output: array(2) { [0]=> string( "testtest" [1]=> string(12) "testtestadsf" } 2
-
Doubtful, not sure why they would require the root@site.com Have you tried it like this... mail("service@site.com", "Register Interest Form Results", $_REQUEST['message'], "From: $_REQUEST['email']", "-f".$_REQUEST['email']); I generally add the -f which simply sets the "from" at the sendmail level. Which generally yields good results. If your host requires it then yes. You need it. If it does not, then no. You can omit it.
-
Honestly, that code is a mess and looks like it is done wrong. I would suggest reading a pagination tutorial which one can be found here As it does seem you do not know how to do it. You should only pull data out of the query that you need, not everything, which the above tutorial will show you how to do.
-
Or use PHP's built in function parse_str that one or a comparable one (seen in the notes of that page).
-
<?php // This is the temporary file created by PHP $uploadedfile = $_FILES['uploadfile']['tmp_name']; // Create an Image from it so we can do the resize $src = imagecreatefromjpeg($uploadedfile); // Capture the original size of the uploaded image list($width,$height)=getimagesize($uploadedfile); // For our purposes, I have resized the image to be // 600 pixels wide, and maintain the original aspect // ratio. This prevents the image from being "stretched" // or "squashed". If you prefer some max width other than // 600, simply change the $newwidth variable $newwidth=600; $newheight=($height/$width)*$newwidth; $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['uploadfile']['name']; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); // NOTE: PHP will clean up the temp file it created when the request // has completed. ?> http://www.4wordsystems.com/php_image_resize.php
-
Just to be clear for future on lookers. This will execute the SQL each time the page is loaded. Not because the link was "clicked". So of course it "looks" like it was dynamic and work. But of course it worked due to the simple fact it always run's on page load. That is not executed cause the user clicked the update link. This is what mchl was getting at. Your code is flawed in that clicking that link would not "re-execute" that code. Not to mention that code you put there has no way to be dynamically generated, give that you did not use variables inside the SQL to allow so. Sorry, that was just bothering me PHP - Hypertext Pre-Processor, meaning all the processing is done before the output is displayed. Only with Javascript making a callback to the server using Ajax would that be possible and make it "look" like it is doing it but really it is making a call back to the server without doing a page reload.
-
Although you were vague and gave us no code to go off of I decided to give you the advice you wanted. Since you did say you want it dynamic to the iframe. You have to know the i-frame's URL before hand dynamically. I am not sure how you get that url, but incorporate it with it. <?php $url = "http://www.zoklet.net"; //replace this with the dynamic url (if there is one). $chandle = curl_init(); curl_setopt($chandle, CURLOPT_URL, $url); curl_setopt($chandle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($chandle, CURLOPT_RETURNTRANSFER, 1); $buffer = curl_exec($chandle); curl_close($chandle); preg_match("~<title>(.*)</title>~is", $buffer, $matches); $title = $matches[1]; ?> <html> <head> <title><?php echo $title;?></title> If you do not have curl you can use file_get_contents instead.
-
If it was me, the issue is going to mainly be in the imagecolorallocate. I do not fully understand how it works. But it is in a loop and if that loop is dynamic depending on a picture/how many colors that picture has....right? Is there a reason to use that in a loop like that. Because a picture that is 702Kb should not be eating up 32MB of memory for a simple resize...there is something wrong with that alone. At most you should only need 3 times the image size to do it, the memory for the uploaded file, the new image and the old image. But, like I said, I do not understand image functions too well, and it may be necessary, although I doubt so. Imagine if someone uploaded a 2MB image, you would need like 300MB of memory just for this script to run, which is totally unacceptable for 1 script/1 person in my book.
-
Remove the 0, that is only needed if you want a range or a starting point (hence only used with select not update). $upfarm = mysql_query("UPDATE land SET type = 'Farm' WHERE userid = '{$mem['id']}' and type = 'none' LIMIT $farm") or die(mysql_error()); And mafia created a syntax error, so do not use that one. I would disagree. If you only want to update 1 record and know 1 record should be updated it is good to specify so. This prevents some mis-haps from happening.
-
The point I am making is that you just want to count the number of times phoneNumber appears right? This is really not a job for regex, regex is more for finding a matches that you do not know, like if you wanted the actual phone number, you would use Regex for that. If that is what you want or your end goal is you need to say that. Because if not, regex is pointless for this and I doubt it can be done. <?php $url = "http://www.yellowpages.com.au/search/postSearchEntry.do?clueType=0&clue=computer+hardware&locationClue=Mordialloc%2C+VIC&x=0&y=0"; $chandle = curl_init(); curl_setopt($chandle, CURLOPT_URL, $url); curl_setopt($chandle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($chandle, CURLOPT_RETURNTRANSFER, 1); $buffer = curl_exec($chandle); curl_close($chandle); $occurances = substr_count($buffer, "phoneNumber"); print $occurances . "\n"; ?> As you can see substr_count can count the number of occurrences much easier than regex. But as I said, if you would like to grab the actual phone numbers, then say so. As what you want was too simple for regex.
-
For something as simple as phonenumber use stristr to test. Regex is not needed for something that simple.
-
http://winscp.net/ Not sure if that is what you are after, as I think that is a client not a server...
-
$sql must be used where it is defined. Since it is not a global character and your function does not return it, it is pointless to define like you have, that and you did not call the function anyhow. What do you have it in a function in the first place? PHP Functions Manual I would suggest looking at proper usage of functions.
-
[SOLVED] Remove error text or anti error check.
premiso replied to Mastha-Hacker's topic in PHP Coding Help
You can use the output buffer methods (ob_start) or choose to add an @ sign to suppress the errors that may come from fsockopen. The output buffer method is shown below, which is better not sure... function pingDomain($domain){ $starttime = microtime(true); ob_start(); $file = fsockopen ($domain, 80, $errno, $errstr, 10); $message = ob_get_contents(); ob_end_clean(); // clean the output to avoid the warning being displayed. // if operation timed out is found, a timeout was reached, set $file to false if (stristr($message, "operation timed out") !== false) $file = false; $stoptime = microtime(true); $status = 0; if (!$file) $status = -1; // Site is down else { fclose($file); $status = ($stoptime - $starttime) * 1000; $status = floor($status); } return $status; } EDIT: Fixed the stristr function to pass the right parameters in the correct order. -
Well give it a try. As long as bar.php is in the directory and actually has code in it, it should process it. I would highly suggest trying stuff instead of just posting and asking. You will find that your question will be answered about 10 time quicker and it will save you and everyone else time. If you want to program you have to try stuff out yourself sometimes. You will not die by trying it out, I promise. And PHP, as far as I know, does not bite...at least very hard.
-
Did you try it?
-
[SOLVED] Error on textarea if Enter is pressed twice
premiso replied to bnther's topic in PHP Coding Help
Well what is your goal. Look at what jack posted for the usage of mail. $to = 'tim@gtwebconcepts.com'; $name = $_POST['Name']; $from = $_POST['Email']; $comments = $_POST['comments']; $subject = "Thank you {$name}"; mail($to, $subject, $comments, "From: {$from}\r\n"); Would probably do what you want. -
$sql = "UPDATE projectData SET position = CASE position WHEN $id THEN $swap WHEN $swap THEN $id END WHERE position IN ($id, $swap) AND proj_id = '$projID'"; You do not need the extra where you had. One where should suffice.
-
That goes along with this saying: Just as disgusting in fact picking McDonalds apart...
-
I have the best idea ever! Variable "contexts"!
premiso replied to tibberous's topic in Miscellaneous
I think you are doing this in vain. Really it is not much work to just do $string = dollar('50.34'); Vs $string:50.02; Granted, I still do not grasp the context syntax/terminology. But yea, I fail to see how it is "easier" than just using a function. Not to mention more confusing, at least with the function people know what to look for/refer to. I do not see how it would be easier/more efficient. Saving what, maybe 10 more characters. an extra 1 or 2 seconds of typing to make it less readable. Not worth it, in my opinion. -
Everyone here volunteers. All donations goes to server costs, which are pretty steep owning a server myself.
-
Javascript is Client side scripting. Meaning that it is controlled after the page has loaded. PHP is server side. They are two different items, apples and oranges. PHP is executed on the server side and thus cannot modify the webpage without a page reload. Where as Javascript can since that is what it is used for. Javascript, as such being on the client side, relies on the client allowing javascript. Where as PHP relies on the server and does not care what the client has. As such you really "cannot" replicate that, other than using CSS 2.0 to create the drop down instead of Javascript, but then again, you are using CSS, which relies somewhat on the client side given that each browser handles it a bit differently.