Jump to content

stefsoko

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

stefsoko's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. How would I incorporate a function to simply check the "name" and "message" for a certain amount of chars, like 15 & 150? <form method="post" action="chat.php"> <p><input name="name" type="text" id="name" value="your name" size="10" maxlength="15"> <input name="message" type="text" id="message" value="your message" size="20" maxlength="150"> <input name="submit" type="submit" id="submit"></p> </form> </body> </html> <?php // when the submit button is clicked if(isset($_POST['submit'])) { // strip any html tags before continuing $name=strip_tags($_POST['name']); $message=strip_tags($_POST['message']); // stop if nothing was entered if($name!='') if($message!='') { // trim any extra whitespace $data=trim($name)."\n"; $data.=trim($message)."\n"; //open the text file and enter the data $file_ar=file("db.txt"); $fp=fopen("db.txt","w"); fputs($fp,$data); if($file_ar!=NULL) { $loop=0; foreach($file_ar as $line) { // do not store more than 20 messages if($loop>=19*3) break; fputs($fp,$line); $loop++; } } fclose($fp); } } // display the messages $fp=fopen("db.txt","r"); while(!feof($fp)) { $name=trim(fgets($fp,999)); $message=trim(fgets($fp,999)); if($name!='') { echo "<p><b>$name: </b>$message</p>"; } } fclose($fp); ?>
  2. so i change the chat.php form action to this... <form action="" method="post"> or <form action="chat.php" method="post"> but what about this line in the core.php file...? header('Location: ./')
  3. would it be ... <form action="core.php" method="post"> and header('Location: chat.php') ?????
  4. I currently have a small 2 page message board, the main file is named index.php and the other core.php - I would like to rename the main file with the form to chat.php, but when I do that, the script no longer posts messages, and goes to the website root. Can someone tell me whats wrong? Here is the form info from the current index.php (that i wish to rename chat.php) <form action="./" method="post"> <p>name (25 chars max)<br> <input id="name" name="author" maxlength="20" size="25"></p> <p>message (150 chars max)<br> <input id="message" name="message" maxlength="150" size="45"></p> <p>what is <?php echo "$num1 &#43; $num2?" ?><br> <input id="captcha" name="captcha" maxlength="2" size="10"></p> <p><input id="submit" name="submit" type="submit" value="submit"> (ip addresses are recorded)</p> </form> and the 2nd file core.php's function that I think is acting up (here or with the form above?) function getPosts() { $author = isset($_POST['author']) ? $_POST['author'] : false; $message = isset($_POST['message']) ? $_POST['message'] : false; global $nameMax; global $messageMax; global $error; if ($author && $message && ($error==false) ) { if (strlen($author) <= $nameMax && strlen($message) <= $messageMax) { $this->inputPost($author, $message); header('Location: ./'); } Why when I rename index.php to chat.php is it not working and falling back to the website root when I submit? any help would be great! I am sure it is something simple, but I am new...
  5. I would like someone to add a functional CAPTCHA to my small 2 page script, if you are interested I posted here: http://www.phpfreaks.com/forums/php-freelancing/need-someone-to-add-captcha-to-form/ I will pay via PayPal immediately after seeing a working example, and you can send the code afterwards! Please reply or PM. Thanks so much!
  6. that doesnt create any errors, but the script then will not post the message? i will PM you denno
  7. here is the entire function if need.. function getPosts() { global $users; global $author; global $message; global $nameMaxChars; global $messageMaxChars; if ($author && $message && ($capatcha == 6 || controlPosts::isAdmin())) { if (strlen($author) <= $nameMaxChars && strlen($message) <= $messageMaxChars) { if ((!controlPosts::isAdmin() && !in_array($author, array_keys($users))) || (controlPosts::isAdmin() && $author == controlPosts::adminName())) { $this->inputPost($author, $message); header('Location: ./'); } } } } } It is currently just checking for a set number as a captcha before posting content. I want to remove this captcha number check, and cannot seem to do so without breaking the script. thanks in advance!!
  8. How do I remove the captcha check on this line and keep it valid? if ($author && $message && ($capatcha == 6 || controlPosts::isAdmin())) I tried if ($author && $message && (controlPosts::isAdmin())) but the script wont post like this?
×
×
  • 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.