LeadingWebDev
-
Posts
79 -
Joined
-
Last visited
Never
Posts posted by LeadingWebDev
-
-
$result= mysql_query($query,$link) if(!$result) { include('memberadd.php'); }
-
short_open_tags = On.
also <? echo $var ?> and <?=$var?> not always works with form correctly.
example:
$var = "Sander van Doorn";
u can experience problem in INPUT will appear only 'Sander'
in this case try using <?=nl2br($var)?>, works well.
hope was helpful.
-
Hi, u need to just store data?
try this:
<?php if(!$_POST) { ?> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <table align="center"> <form name="text_field_store_data" action="<?=$_SERVER['PHP_SELF']?>" method="POST"> <tr> <td> <textarea name="textfield" cols="45" rows="5" id="textfield">Text</textarea></td> </tr> <tr> <td align="center"> <input name="submit" type="submit" id="button" value="Submit" onClick=""></td> </tr> </form> </table> </body> <? } else { $myFile = "testFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $_POST['textfield']; // may u protect the string? if(!fwrite($fh, $stringData)) { echo "error appear while trying to store data"; }else{ fclose($fh); echo "Successfuly stored"; echo "<meta http-equiv='REFRESH' content='2;url=$_SERVER[REQUEST_URI]'>"; } } ?> </html>
why we do a checking if(!$_POST) if not post in other words, if visitor didnt clicked on Submit he will see only 1st part of script, that contains HTML form only, else he will not see a form, but php part will execute and store data, if script cant open file, error appears, if script cant save data for any reason the error will apeare, if all operation success - Successfuly stored, and will redirect visitor to the same form.
Hope it was helpful.
PHP Code Question
in PHP Coding Help
Posted
mail() may work not correctly if your mail box located at same host. 1 time i had this trouble.