Jump to content

Recommended Posts

Here is the code for my message page and below it the code that posts the message. Can anyone please show me how to add a character limit of 3000 to the message/textarea?

 

message page:

 

<?php

 

// Get the file

$file = implode('', file ("post.xml"));

 

print "

<form action=post.php method=post>

<input type=hidden name=post value=yes>

<p>

Your Name<br>

<input type=text name=name size=30>

</p>

<p>

Message<br>

<textarea name=message rows=5 cols=50></textarea>

</p>

<p>

<input type=submit value=\"Post\">

<input type=reset value=Reset>

</p>

</form>";

 

?>

 

action page:

 

<?php

 

$name=$_POST['name'];

$message=$_POST['message'];

 

// Name and Message required

if (( $name == "") || ( $message == "")) {

print "<p align=center>Please go back to complete all fields!<p>";

}

else {

 

//Get the file

$file_name = "post.xml";

$file_pointer = fopen($file_name, "r+");

$lock = flock($file_pointer, LOCK_EX);

$file_read = fread($file_pointer, filesize($file_name));

 

//$name = strip_tags($name, '');

//$message = strip_tags($message, '');

 

$date = date ("j M Y");

$post = "\n\n<ponmurt>\n<p><span class=name>$name</span><span class=date> $date</span><br>$message</p>\n</ponmurt>";

 

//Paste the updated info into the file

$post = stripslashes($post);

fwrite($file_pointer, "$post");

fclose($file_pointer);

 

print "<head><meta http-equiv=refresh content=0;URL=index.php></head>";

}

 

?>

Would this be the correct way to add it?

 

// Name and Message required

if (( $name == "") || ( $message == "")) {

print "<p align=center>Please go back to complete all fields!<p>";

}

if (strlen($message) > 3000) {

print "<p align=center>Too long!<p>";

}

else {

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.