• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

Formular überprüfen

Status
Für weitere Antworten geschlossen.

dreamweaver_8

Neues Mitglied
Hallo,

ich habe wieder einmal ein Problem.

PHP:
<?php
// prueft die mail und checkt ob die domain der mail erreichbar ist !
function checkMail($mail)
{
  if( (preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $string)) || (preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/',$string)) ) 
  { 
    $host = explode('@', $string);
 
    if(!function_exists('checkdnsrr')) 
    {
      function checkdnsrr($host, $type = '') 
      {
        if(!empty($host)) 
        {
          if($type == '') 
          {
            $type = "MX";
          }
 
              @exec("nslookup -type=$type $host", $output);
 
              while(list($k, $line) = each($output)) 
          {
                  if(eregi("^$host", $line)) 
            {
                              return true;
            }
                 }
 
                  return false;
              }
          }
      }
      if(checkdnsrr($host[1].'.', 'MX') ) return true;
      if(checkdnsrr($host[1].'.', 'A') ) return true;
      if(checkdnsrr($host[1].'.', 'CNAME') ) return true;    
 
    return false;    
  }
}
if(isset($_POST['sender']))
{
  // entfernt die whitespaces vor und nach der eingabe 
  // so verhinderst du, das einer ein leeres feld mit whitespaces abschickt
  $benuzername         = trim($_POST['benuzername']);
  $mail      = trim($_POST['mail']);
 
  // ueberprueft ob die felder leer sind  
  if(checkMail($mail) && !empty($benutzername))
  {
  header("Location: http://www.mybild.manug.ch/?mybildid=add2");
  }
  else
  {
  echo "Deine Daten sind ungültig bitte korigiere sie!" ;
  }
}
?>
<?php require_once('../Connections/MYPIC.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
  $insertSQL = sprintf("INSERT INTO profil (benuzername, mail) VALUES (%s, %s)",
                       GetSQLValueString($_POST['benuzername'], "text"),
                       GetSQLValueString($_POST['mail'], "text"));
  mysql_select_db($database_MYPIC, $MYPIC);
  $Result1 = mysql_query($insertSQL, $MYPIC) or die(mysql_error());
  $insertGoTo = "http://www.mybild.manug.ch/?mybildid=add";
  header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Unbenanntes Dokument</title>
</head>
<body>
<form method="post" name="form2" action="<?php echo $editFormAction ?>"><input type="hidden" name="MM_insert" value="form2">
    <table cellspacing="0" cellpadding="1" width="420" border="0">
      <tbody>
        <tr>
          <td colspan="3"><div>
              <h1>Profil erstellen</h1>
          </div></td>
        </tr>
        <tr>
          <td>E-Mail Adresse</td>
          <td colspan="2"><input type="text" name="mail" value="" size="32" /></td>
        </tr>
        <tr>
          <td>Benutzername</td>
          <td><input type="text" name="benuzername" value="" size="32" /></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><input type="submit" name="Submit2" value="Weiter&gt;" id="Submit2" /></td>
        </tr>
      </tbody>
    </table>
</form>
  <p>&nbsp;</p>
  </label>
  </form>
<p>&nbsp;</p>
</body>
</html>


Es passiert nichts... Nach dem absenden Kommt wieder die gleiche seite, und es wird ein eintrag in die db gemacht.


Eigentlich sollte es beide felder auf ihre richtigkeit überprüfen...
 
Werbung:
diese pingfunktionen wie dnsrr usw funzen bei mir nie richtig... meine chkemail sieht so aus:

PHP:
<?php
function mp_chkemail($emstr) {
 $ch4hk = htmlentities($emstr);
 if ( $emstr == $ch4hk ) {
  if ( ereg('@', $emstr) ) {
   $emparts = explode('@', $emstr);
   if (count($emparts) < 3) {
    $em_1 = $emparts[0];
    $em_2 = $emparts[1];
    $tlds = array(
     1=>'AERO','ARPA','BIZ','COM','COOP','EDU','GOV','INFO','INT','MIL','MUSEUM','NAME',
     'NATO','NET','ORG','PRO','AD','AE','AF','AG','AI','AL','AM','AN','AO','AQ','AR',
     'AS','AT','AU','AW','AZ','BA','BB','BD','BE','BF','BG','BH','BI','BJ','BM','BN',
     'BO','BR','BS','BT','BV','BW','BY','BZ','CA','CC','CF','CG','CH','CI','CK','CL',
     'CM','CN','CO','CR','CS','CU','CV','CX','CY','CZ','DE','DJ','DK','DM','DO','DZ',
     'EC','EE','EG','EH','ER','ES','ET','EU','FI','FJ','FK','FM','FO','FR','FX','GA',
     'GB','GD','GE','GF','GH','GI','GL','GM','GN','GP','GQ','GR','GS','GT','GU','GW',
     'GY','HK','HM','HN','HR','HT','HU','ID','IE','IL','IN','IO','IQ','IR','IS','IT',
     'JM','JO','JP','KE','KG','KH','KI','KM','KN','KP','KR','KW','KY','KZ','LA','LB',
     'LC','LI','LK','LR','LS','LT','LU','LV','LY','MA','MC','MD','MG','MH','MK','ML',
     'MN','MO','MP','MQ','MR','MS','MT','MU','MV','MW','MX','MY','MZ','NA','NC','NE',
     'NF','NG','NI','NL','NO','NP','NR','NT','NU','NZ','OM','PA','PE','PF','PG','PH',
     'PK','PL','PM','PN','PR','PT','PW','PY','QA','RE','RO','RU','RW','SA','Sb','SC',
     'SD','SE','SG','SH','SI','SJ','SK','SL','SM','SN','SO','SR','ST','SU','SV','SY',
     'SZ','TC','TD','TF','TG','TH','TJ','TK','TM','TN','TO','TP','TR','TT','TV','TW',
     'TZ','UA','UG','UK','UM','US','UY','UZ','VA','VC','VE','VG','VI','VN','VU','WF',
     'WS','XXX','YE','YT','YU','ZA','ZM','ZR','ZW');
    $domainparts = explode('.', $em_2);
    $tldkey = count($domainparts)-1;
    $tld = strtoupper($domainparts[$tldkey]);
    $proof = 0;
    foreach ( $tlds AS $value ) {
     if ( $tld == $value ) {$proof = 1;}
    }
    if ( $proof == 1 ) {
     if (eregi("^[a-zA-Z0-9]+((\.|-|_)[a-zA-Z0-9]+)*$",$em_1)) {
      RETURN TRUE;
     } else {
      RETURN FALSE;
     }
    } else {
     RETURN FALSE;
    }
   } else {
    RETURN FALSE;
   }   
  } else {
   RETURN FALSE;
  }
 } else {
  return FALSE;
 }
}
 
Status
Für weitere Antworten geschlossen.
Zurück
Oben