Problema validare formular
Scris: Vin Mai 18, 2012
Cod: Selectaţi tot
<?php
session_start();
include "connect_to_mysql.php";
$id_adaugare_anunt = $_SESSION['id'];
$sql = mysql_query("SELECT * FROM members WHERE id='$id_adaugare_anunt' LIMIT 1");
while($row = mysql_fetch_array($sql)){
$judet_adaugare_anunt = $row["judet"];
$localitate_adaugare_anunt = $row["localitate"];
$accounttype_adaugare_anunt = $row["accounttype"];
$despre_adaugare_anunt = $row["despre"];
$nume_user_adaugare_anunt = $row["nume_user"];
$prenume_user_adaugare_anunt = $row["prenume_user"];
$email_adaugare_anunt = $row["email"];
$website_adaugare_anunt = $row["website"];
}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript"><!--
// RegExp care sa permite doar litere, numere si liniute "-", "_"
var regx_chr = /^([0-9,\.]+)$/;
var regx_mail = /^([a-zA-Z0-9]+[a-zA-Z0-9._%-]*@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4})$/; // RegExp pt. adresa e-mail
// Functia care e apelata la "onsubmit"
// preia campurile din formular, verifica /valideaza datele adaugate
function checkForm(frm1) {
var fre = false; // variabila ce va fi returnata de functie
// preluare casete formular
var pret1 = frm1.pret1;
var nrtel1 = frm1.nrtel1;
var email1 = frm1.email1;
// verificare valori (Nume, Parola, E-mail), daca sunt incorecte, returneaza alert si selecteaza casuta
if(pret1.value.length<1 || pret1.value.length>9 || pret1.value.search(regx_chr)==-1) {
alert('Pretul trebuie sa contina doar numere!');
pret1.select(); // selecteaza casuta pt. Nume
}
else if(email1.value.search(regx_mail)==-1) {
alert('Adaugati o adresa de e-mail corecta');
email1.select(); // selecteaza casuta pt. E-mail
}
else if(nrtel1.value.length<10 || nrtel1.value.length>30 || nrtel1.value.search(regx_chr)==-1) {
alert('Numarul de telefon trebuie sa fie format din minim 10 si maxim 30 de numere!');
nrtel1.select(); // selecteaza casuta pt. Parola
}
else fre = true;
return fre;
}
--></script>
<style type="text/css">
<!--
.style1 {
color: #CC0000;
font-size: 16px;
font-weight: bold;
}
.style3 {font-size: 18px}
-->
</style>
</head>
<body>
<div align="center"><span class="style1">Completati toate radurile urmatoare</br>
Poza nu este obligatorie</span></div>
<table width="652" height="405" border="1">
<tr>
<td width="202"><div align="right">Sunteti: </div></td>
<td colspan="3"><strong><form name="adaugare" method="post" enctype="multipart/form-data" action="insert.php">
<input type="radio" name="sunteti" value="Persoana" required="required"/>
Persoana
<input type="radio" name="sunteti" value="Companie" required="required"/>
Companie
</strong></td>
</tr>
<tr>
<td><div align="right">Categorie Anunt: </div></td>
<td colspan="3"><select name="categorie">
<option value="0" selected="selected">categorie anunt...</option>
<option value="1">Afaceri</option>
<option value="2">Agricole</option>
<option value="3">Animale</option>
<option value="4">Anticariat</option>
<option value="5">Arta si Antichitati</option>
<option value="6">Auto</option>
<option value="7">Colectii</option>
<option value="8">Computere</option>
<option value="9">Constructii</option>
<option value="10">Diverse</option>
<option value="11">Donatii si Sponsorizari</option>
<option value="12">Electronice si Electrotehnice</option>
<option value="13">Foto</option>
<option value="14">Hobby</option>
<option value="15">Imobiliare</option>
<option value="16">Locuri de munca</option>
<option value="17">Moda</option>
<option value="18">Mobilier</option>
<option value="19">Moto-Velo</option>
<option value="20">Media si Publicitate</option>
<option value="21">Muzica</option>
<option value="22">Pierderi si Gasiri</option>
<option value="23">Servicii</option>
<option value="24">Sport</option>
<option value="25">Turism</option>
<option value="26">Telefoane</option>
</select></td>
</tr>
<tr>
<td><div align="right">Subcategorie Anunt: </div></td>
<td colspan="3"></td>
</tr>
<tr>
<td><div align="right">Titlu Anunt:</div></td>
<td colspan="3"><input type="text" name="titluanunt" maxlength="87" id="titluanunt1"/></td>
</tr>
<tr>
<td><div align="right">Text Anunt: </div></td>
<td colspan="3"><textarea rows="10" cols="30" name="textanunt" id="textanunt1"> </textarea></td>
</tr>
<tr>
<td><div align="right">Pret:</div></td>
<td width="174"><input type="text" name="pret" id="pret1"/></td>
<td width="93"><div align="right">Moneda:</div></td>
<td width="155"><strong>
<select name="moneda">
<option value="RON">RON</option>
<option value="EUR">EUR</option>
<option value="USD">USD</option>
</select>
</strong></td>
</tr>
<tr>
<td><div align="right">Adresa e-mail:</div></td>
<td colspan="3"><input type="text" name="email" id="email1" value="<?php echo $email_adaugare_anunt; ?>" /></td>
</tr>
<tr>
<td><div align="right">Numar de telefon:</div></td>
<td colspan="3"><input type="text" name="nrtel" id="nrtel1"/></td>
</tr>
<tr>
<td><div align="right">Judet:</div></td>
<td colspan="3"><select name="judet">
<option value="Alba">Alba</option>
</select></td>
</tr>
<tr>
<td><div align="right">Localitate:</div></td>
<td colspan="3"><input type="text" name="localitate"/></td>
</tr>
<tr>
<td><div align="right">Imagine</div></td>
<td colspan="3"><input type="file" name="uploaded_file" /></td>
</tr>
<tr>
<td><div align="right">Durata anunt: </div></td>
<td colspan="3"><select name="zile">
<option value="7">O saptamana</option>
<option value="14">Doua saptamani</option>
<option value="30">O luna</option>
<option value="60">Doua luni</option>
<option value="90">Trei luni</option>
<option value="180">Sase luni</option>
<option value="365">Un an</option>
<option value="730">Doi ani</option>
</select></td>
</tr>
<tr>
<td><div align="right">Adauga codul din casuta rosie:</div></td>
<td colspan="3" bordercolor="#00CCFF"><p align="left"><img src="captcha/captcha.php" alt="Please, write the code."> </p>
<p align="left">
<input name="code" type="text" />
</p></td>
</tr>
<tr>
<td colspan="4"><input type="checkbox" name="vehicle" value="Bike" required="required"/>
Am verificat anuntul, care este corect si complet<br />
<input type="checkbox" name="vehicle" value="Car" required="required"/>
Am citit si sunt de acord cu <a href="termeni.php" class="style3">termenii de utilizare</a> pentru adaugarea anunturilor </td>
</tr>
<tr>
<td colspan="4"><div align="center">
<input type="image" name="Submit" src="imagini/butoane/buton_adauga_anunt.jpg" width="200" height="36" id="fsubmit"/></form>
</div></td>
</tr>
</table>
</body>
</html>
chiar daca bag pretul in litere sau nr de telefon nu imi apare nici un avertisment.scriptul ruleaza ca si cum nu s-ar intampla nimic
Multumesc