Hello again:
some one told me to control the "input" and "text areas" right filling in
from a form using java script and this is what I'm trying but problems


the javascript is doing it's work but nothing is inserted in the db if using
<input OnClick="envia();" type="button" name="submit_opina" value="opina">

the javascript checks (only) the filling in of the first input and after
this the form is
submited without more checking, empty fields are submited
<input OnClick="envia();" type="submit" name="submit_opina" value="opina">

some help please?
thanks in advance

Ani López
Visit us, download and spread our music

------ opinion.php file -------
<title>PHP + JavaScript fill in inputs control</title>
<script language="javascript" type="text/javascript">
function envia(){
 if (document.opina.name_in.value.length < 1){
 window.alert('Write your name');
 } else if (document.opina.email_in.value == "" ||
document.opina.email_in.value.indexOf('@', 0) == -1){
 window.alert('Write your email');
 } else if (document.opina.text_in.value.length < 1){
 window.alert('Your opinion please');
 } else {
<body bgcolor="#FFFFFF">

<!-- db conexion -->
<?php $dbcnx = @mysql_connect ("localhost", "xxxxx", "xxxxxx");
mysql_select_db ("xxxxxxxx", $dbcnx); ?>

<!-- Insert to db opinion form -->
<form name="opina" action="<?php echo($PHP_SELF); ?>" method="POST">
<table border="0">
  name <input size="26" name="name_in"><br>
  email <input size="28" name="email_in"><br>
  text <br><textarea name="text_in" rows="4" cols="65"></textarea><br>
  <input OnClick="envia();" type="button" name="submit_opina" value="opina">
if ("opina" == $submit_opina) {
 $sql = "INSERT INTO opinion SET " . "nombre = '$nombre_in', " . "email =
'$email_in', " . "texto = '$texto_in', " . "fecha = CURDATE()";

<!-- select, show opinions and db conexion closing-->
 $result = mysql_query("SELECT nombre, email, texto, fecha FROM opinion
ORDER BY fecha DESC");
 while ( $row = mysql_fetch_array($result) ) {
 $nombre_db = $row["nombre"];+
 $email_db = $row["email"];
 $texto_db = $row["texto"];
 $fecha_db = $row["fecha"];
 "<table width='550' border='0' cellspacing='0' cellpadding='7'>
  <td><a href='mailto:$email_db' class='enlace'><b>$nombre_db</b></a></td>
  <td><span class='txt_p'>$fecha_db</span></td>
  <td colspan='2'><p align='justify'>$texto_db</p></td>
 $dbdecnx = mysql_close ($dbcnx);

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to