Jump to content

[SOLVED] Validating Inputs


ballouta

Recommended Posts

Hello

 

I just finished testing this piece of simple validation:

 

<?php
$title = $_POST['title'];
$short = $_POST['short'];
$long = $_POST['long'];

if (empty($title))
echo "Please insert a title<br>";
elseif (is_numeric ($title))
echo "Title should not contain only numbers<br>";
elseif (strlen($title) > 10)
echo "Good title should be at least 10 characters<br>";
else
echo "Title accepted";

if (empty($short))
echo "Please insert a short description<br>";
elseif (is_numeric ($short))
echo "Short Description should contain some letters<br>";
elseif (strlen ($short) < 100)
echo "Short description should be at least 100 characters<br>";
else
echo "Short description is accepted";

if (empty ($long))
echo "Please Enter a long description";
elseif (is_numeric ($long))
echo "Long Description should contain some letters<br>";
elseif (strlen ($long) <150)
echo "Good Long description should contain at least 150 characters<br>";
else
echo "Long description is accepted";
?>

 

I want to insert the three variables into the DB if they pass all these validation lines.

How it can be done?

 

Many thanks

 

Link to comment
https://forums.phpfreaks.com/topic/153669-solved-validating-inputs/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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