pajhonka Posted September 22, 2010 Share Posted September 22, 2010 Hi, I have a Flash contact form that sends its name, e-mail, and message variables to a PHP script. The script works fine if the message is under ~700 characters, but anything more and the script won't post the message at all. An e-mail with just the name and e-mail address will come through to my inbox (which is embarrassing as a potential client sent me a contact form e-mail about a development job ). Is there some way to check the maximum character length for a string variable? Or to set its length to something higher? This is my php. Thank you!! <? $senderName = $_POST['userName']; $senderEmail = $_POST['userEmail']; $senderMessage = $_POST['userMsg']; $senderName = stripslashes($senderName); $senderMessage = stripslashes($senderMessage); $senderMessage = strip_tags($senderMessage, '<p><br>'); $to = "[email protected]"; $from = "[email protected]"; $subject = "E-mail from $senderName"; $message = "<p><font size='2.5' face='Helvetica Neue, Helvetica, Sans Serif'><b>FROM:</b> $senderName <br><br> <b>E-MAIL:</b> <a href='mailto:$senderEmail'>$senderEmail</a> <br><br> <b>MESSAGE:</b> $senderMessage</p>"; $headers = "From: $from\r\n"; $headers = "MIME-Version: 1.0\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $to = "$to"; mail($to, $subject, $message, $headers); $my_msg = "Thanks $senderName, your message has been sent."; print "return_msg=$my_msg"; exit(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/214146-maximum-string-variable-length-in-contact-form/ Share on other sites More sharing options...
fortnox007 Posted September 22, 2010 Share Posted September 22, 2010 maybe use strlen()? like $string = 'I am king of the world'; if (strlen($string)>20){ echo 'string longer than 20'; }else{ echo 'shorter (or equal) than 20'; } Quote Link to comment https://forums.phpfreaks.com/topic/214146-maximum-string-variable-length-in-contact-form/#findComment-1114312 Share on other sites More sharing options...
PFMaBiSmAd Posted September 22, 2010 Share Posted September 22, 2010 The only limit, as far as php is concerned, is the amount of memory available. There are 'security' patches that could impose such limits and your web host might be using it/them. Start by checking if your php script is receiving what you expect. Add the following to your php code - echo "<pre>"; echo "POST:"; var_dump($_POST); echo "</pre>"; Php does impose a maximum size of all the post data using the post_max_size setting (AFIAK exceeding this will result in an empty $_POST array, not simply data cut off at some point.) The default post_max_size setting is 8M. Quote Link to comment https://forums.phpfreaks.com/topic/214146-maximum-string-variable-length-in-contact-form/#findComment-1114314 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.