Do not allow posting of whitespace
Posted on
16th Feb 2014 07:03 pm by
admin
Currently the script below works if the user does not type a name/message, but if i create a whitespace with the spacebar, it will submit. How would I fix this?
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
<input type=text name=name size=30>
</p>
<p>
Message
<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 = "nn<ponmurt>n<p><span class=name>$name</span><span class=date> $date</span>
$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>";
}
?>
No comments posted yet
Your Answer:
Login to answer
191
17
Other forums
LOOPing Problem
Hello All!
The following code loops through the data and displays the data accordingly. My p
Not sure why this script is not working?
Hi I am new to php programing and I was trying to make up a simple script like a captcha but I canno
how make 2 column in table with data tybe long row
hi every one
I want make in my table 2 column with data tybe long raw
how thi
need help to creat database
Hello Team, please guys i am stuck from three days with paypal issue for IPN but no luck yet now i w
Hi, explode and strstr.
Hi, I seem to be confused about the strstr function, eg. i have a string like:
"a.b.c.d.e.f&
If a record matches an existing record do nothing
So I don't know if I should put this here or in mysql, but what my script is for is for people to ad
This is driving me nuts!
This insert query looks to be alright, however I get this error:
QuoteYou have an error in yo
Email Script does not reach destination
Hey Guys look at this code snippet :
Code:
//read a line from the file
$myFile = "
Downloading file (Headers)
I'm trying to make users download a file, but they must wait 60 seconds before it begins.
But
MII Netweaver Server stopped due to CPIC connection Problem
Dear Experts,
We have SAP XMII 12.0 setup running on Netweaver 2004s,7.0, Java Stack only.