Page 1 of 1

PhP validation fields

Posted: Tue Nov 05, 2013 12:11 pm
by digiman
Hello everyone.Since its my first time implementing with php i thought i could ask some questions for a form i made.
This is the form.

Code: Select all

<!DOCTYPE HTML>
<html>
<head>
<title>Print Center</title>
  <link rel="stylesheet" href="style.css" type="text/css" media="screen">
<SCRIPT LANGUAGE="JavaScript">
function CheckAdd() {
if (document.form.number.value == "") {
  alert("please insert number!");
  return false;
            }
            if (document.form.name.value == "") {
  alert("please insert name!");
  return false;
            }
            if (document.form.date.value == "") {
  alert("please insert date!");
  return false;
            }
			 if (document.form.cvc.value == "") {
  alert("please insert cvc!");
  return false;
            }
			if (document.form.adress.value == "") {
  alert("please insert adress!");
  return false;
            }
            
				 
           
  }
  </script>
<style>
.error {color: #FF0000;}
body {
	background-color: #e6e5d7;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7"></head>
<body>



<h2>Please insert you card elements</h2>
<h2>and the sendind procedure.</h2>
<p>&nbsp;</p>
<form action="buy4.php" method="POST" enctype="multipart/form-data" name="form" id="form" onSubmit="return CheckAdd()">
<div style>

<font size="+1">Card number:</font><input type="text" name="number" size="50" maxlength="100">

<br><br>
 <font size="+1">Name:</font><input type="text" name="name" size="50" maxlength="100">
   
   <br><br>
   <font size="+1">Expiration date:</font><input type="text" name="date" size="50" maxlength="100">
   
   <br><br>
   <font size="+1">CVC2:</font> <input type="password" name="cvc" size="50" maxlength="100">
   
   <br><br>
   <font size="+1">Send adress:</font><input type="text" name="adress" size="50" maxlength="100">
    <br><br>
   <font size="+1">Transporting Company:</font>
  
   <input type="radio" name="way"  value="way">Wego
   <input type="radio" name="way"  value="way">Levi trasport
   <br><br>
   <span class="error">*Expenses for sending are charged to the customer</span>
   
   
   
   
   <br><br>
   
  
   <br><br>
   <input type="reset" name="reset" value="clear">
            <input type="submit" name="send" value="continue" onClick="return CheckAdd()">
   
</form>







</body>
</html>

Problem is i want to check (with php) if the name is only letters and span an error if its not
// // if the Exp.date is of a date structure and span an error if its not
// // if the cvc is of numbers only and span an error if its not
Thats about it.
Sorry if im beeing way out of line for just asking for code but all attempts i've tried have failed and i cant get myself around it :banghead: .
If you dont want to directly help me please point me in the right directions(a site or your opinion)

Re: PhP validation fields

Posted: Tue Nov 05, 2013 2:38 pm
by Christopher
Can you post what you have in your buy4.php file so far?

Re: PhP validation fields

Posted: Tue Nov 05, 2013 4:18 pm
by digiman
uhm yes but...the only thing that buy4 does is just delete a product from my dbase based on a code thats been submitted.
on the current form that im showing all the fields are iconic,none of them are beeing checked/inserted to the dbase.
The checks i need are just for the fields for letters,number,date kiiinda something like this http://www.w3schools.com/php/php_form_complete.asp.
Hope i said everything right and sorry for my lack of knowledge in php. :(
Thnks a lot for answering though! :D

Re: PhP validation fields

Posted: Wed Nov 06, 2013 6:29 am
by Celauran
Sounds like a simple ctype_alpha() check will do, though you could achieve the same via regex.