ballouta Posted April 11, 2009 Share Posted April 11, 2009 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 More sharing options...
jackpf Posted April 11, 2009 Share Posted April 11, 2009 For each pass you could do $pass += 1; And then at the end do if($pass == 3) { //user has passed } Link to comment https://forums.phpfreaks.com/topic/153669-solved-validating-inputs/#findComment-807518 Share on other sites More sharing options...
jackpf Posted April 11, 2009 Share Posted April 11, 2009 You are welcome... Link to comment https://forums.phpfreaks.com/topic/153669-solved-validating-inputs/#findComment-807626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.