I am trying to write a script that includes if/else statements and functions. some background
$partsfirst character should have the letter "N"$descis suppose to be at least one character long$priceneeds to be positive (0 or higher)
if all three of theses requirements are met then it should say "data accepted" if something is not met (one or all) the "Invalid...." needs to show.
can someone tell me what part of my script I should look at.
<?php
$parts = $_POST["parts"];
$desc = $_POST["desc"];
$price = $_POST["price"];
$pa = substr($parts, 0, 1);
$de = strlen($desc);
if ($pa != "N")
{echo "Invalid Part Number";}
else
if ($de <= 1)
{echo "Invalid Description Length";}
else
if ($price <= 0)
{echo "Invalid Price";}
else
{echo "Data Accepted";}
?>
$pa != Nis not going to work N should be wrapped in quotes, and then it will only check if the variable is equal to N and not a sub string of the variable is equal to N. I would look at the use ofsubstrto get that working right.