I have this simple on how Function trim() work, but it is not working. Can someone tell me why?
If you notice on the code below in first input tag where my name goes I left planty of spaces at the left side of my name (Masood). I assume the trim() should take them out. I have run the code and show the result at the end of this posting.
<html>
<head>
<title>Bob's Auto Parts - Customer Feedback</title>
</head>
<body>
<h1>Customer Feed Back</h1><br />
Please tell us what you think
<form action="processfeedback2.php" method="post">
Your name <br />
<input type="text" name="name" value = " Masood" size="40" /><br />
Your email address<br />
<input type="text" name="email" value='masood131@yahoo.com' size="40" /><br />
Your feedback<br />
<textarea rows="5" cols="30" name="feedback" value="This is just a test"></textarea><br />
<input type="submit" value="Send feedback" size="40" />
</form>
</body>
</html>
Here is the processcode2, which processes feedback.html
<?php
//create short variable
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
?>
<html>
<head>
<title>Bob's Auto Parts- Feedback Submitted</title>
</head>
<body>
<h1>Feedback Submitted</h1>
<p>Your feedback has been sent.</p>
<?php
echo "This is name ".'<strong><u>'.before.'</u></strong>'. " running the function trim() <br />";
echo $name.'<br /><br />';
echo "This is name ".'<strong><u>'.after.'</u></strong>'. " running the function trim() <br />";
$name = trim($name);
echo $name;
?>
</body>
</html>
and here is what I get as a result:
Feedback Submitted
Your feedback has been sent.
This is name before running the function trim()
Masood
This is name after running the function trim()
Masood
Ty
masood