Results 1 to 2 of 2

Thread: registration problem

Hybrid View

  1. #1
    Join Date
    Jun 2010

    registration problem

    session_start(); // Alltid &#246;verst p&#229; sidan
    include "conn.php"; // Databasanslutningen
    if (isset($_POST['submit'])){
      $_POST = db_escape($_POST);
      // Tag bort eventuella blanksteg i b&#246;rjan eller slutet
      foreach($_POST as $key => $val){
        $_POST[$key] = trim($val);
      //Kolla efter tomma f&#228;lt
      if (empty($_POST['personnr']) || empty($_POST['password']) || empty($_POST['password2']) || empty($_POST['orgnr']) || empty($_POST['namn']) || empty($_POST['efternamn']) || empty($_POST['adress']) || 
          empty($_POST['ort']) || empty($_POST['postnr']) || empty($_POST['telefonnr']) || empty($_POST['mobilnr']) || empty($_POST['epost'])) {
        $reg_error[] = 0;
      // Kolla om anv&#228;ndarnamnet &#228;r upptaget
      $sql = "SELECT COUNT(*) FROM arbetsgivare WHERE namn='{$_POST['namn']}'";
      $result = mysql_query($sql);
      if (mysql_result($result, 0) > 0) {
        $reg_error[] = 1;
      // Kolla om e-post kan t&#228;nkas vara ok
      if (!preg_match('/^[-A-Za-z0-9_.]+[@][A-Za-z0-9_-]+([.][A-Za-z0-9_-]+)*[.][A-Za-z]{2,6}$/', $_POST['epost'])) {
        $reg_error[] = 2;    
      // Kolla s&#229; att l&#246;senorden st&#228;mmer &#246;verrens
      if ($_POST['password'] != $_POST['password2']) {
        $reg_error[] = 3;
      // Inga fel? Spara och logga in samt skicka till v&#228;lkomstsida
      if (!isset($reg_error)) {
        $sql = "INSERT INTO arbetsgivare(personnr, password, password2, orgnr, namn, efternamn, adress, ort, postnr, telefonnr, mobilnr, epost)
                VALUES('{$_POST['personnr']}', '{$_POST['password']}', '{$_POST['password2']}', '{$_POST['orgnr']}', '{$_POST['namn']}' '{$_POST['efternamn']}', '{$_POST['adress']}', '{$_POST['ort']}', '{$_POST['postnr']}', '{$_POST['telefonnr']}', '{$_POST['mobilnr']}', '{$_POST['epost']}',";
        $_SESSION['sess_id'] = mysql_insert_id();
        $_SESSION['sess_namn'] = $_POST['namn'];
        header("Location: index.php");
    } else {
      // S&#228;tt variabler f&#246;r tomt formul&#228;r
      for ($i=0; $i<4; $i++) {
        $back[$i] = "";
    $error_list[0] = "Alla f&#228;lt &#228;r inte infyllda";
    $error_list[1] = "Anv&#228;ndarnamnet &#228;r upptaget";
    $error_list[2] = "Felaktig e-postadress";
    $error_list[3] = "L&#246;senorden st&#228;mmer inte &#246;verrens";
    <!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">
    	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    	<meta name="keywords" content="bemanning, arbete, arbetstagare, arbetsgivare"/>
    	<meta name="description" content="Bemanningsf&#246;retag"/>
    	<link href="bemanning24_css2.css" rel="stylesheet" type="text/css"/>
    	<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    	<script src="js/login.js"></script>
    	<body><div id="skugga_left"></div>
    	<div id="skugga_right"></div>
    <div id="container">
    	<div id="header">
    	<div id="nav">
    			<li><a href="index.php" class="selected" title="Start">Start</a></li>
    			<li><a href="#" title="Arbetstagare">Arbetstagare</a></li>
    			<li><a href="#" title="Arbetsgivare">Arbetsgivare</a></li>
    			<li><a href="omoss.php" title="Om Oss">Om Oss</a></li>
    			<li><a href="kontakt.php" title="Kontakt">Kontakt</a></li>
    		<div class="login"><!-- Login Starts Here -->
                <div id="loginContainer">
                    <a href="#" id="loginButton"><span>Login</span><em></em></a>
                    <div style="clear:both"></div>
                    <div id="loginBox">                
                        <form id="loginForm">
                            <fieldset id="body">
                                    <label for="email">Anv&#228;ndarnamn</label>
                                    <input type="text" name="email" id="email" />
                                    <label for="password">L&#246;senord</label>
                                    <input type="password" name="password" id="password" />
                                <input type="submit" id="login" value="Sign in" />
                                <label for="checkbox"><input type="checkbox" id="checkbox" />Kom ih&#229;g mig</label>
                            <span><a href="#">Gl&#246;mt l&#246;sen?</a></span>
                <!-- Login Ends Here --></div>
    	<div id="content">
    		<div id="page">
    				if (isset($reg_error)){
    				  echo "N&#229;got blev fel:<br>\n";
    				  echo "<ul>\n";
    				  for ($i=0; $i<sizeof($reg_error); $i++) {
    					echo "<li>{$error_list[$reg_error[$i]]}</li>\n";
    				  echo "</ul>\n";
    				  $back[0] = stripslashes($_POST['personnr']);
    				  $back[2] = stripslashes($_POST['epost']);
    				  $back[3] = stripslashes($_POST['password']);
    			<h2>Registrera en arbetsgivare:</h2>
    				<form method="post" name="post" action="reg_arbetsgivare.php">
    				<input type="text" class="form" name="personnr" value="<?php echo $back[0];?>" /><br />
    				<input type="text" class="form" name="password" value="<?php echo $back[3];?>" /><br />
    				Repetera L&#246;senord:
    				<input type="text" class="form" name="password2" /><br />
    				<input type="text" class="form" name="orgnr" /><br />
    				<input type="text" class="form" name="namn" size="20" /><br />
    				<input type="text" class="form" name="efternamn" /><br /> 
    				<input type="text" class="form" name="adress" /><br />
    				<input type="text" class="form" name="ort" /><br />
    				<input type="text" class="form" name="postnr" /><br />
    				<input type="text" class="form" name="telefonnr" /><br />
    				<input type="text" class="form" name="mobilnr" /><br />
    				<input type="text" class="form" name="epost" value="<?php echo $back[2];?> " /><br />
    				<input type="submit" name="submit" class="skicka_knapp" value="L&#228;gg till!" />
    				<p><a href="inloggad.php">Bak&#229;t</a></p>
    			//Alternativt ist&#228;llet f&#246;r ob_start- och flush placera hela detta scriptet ovanf&#246;r htmlkoden!
    			if (isset($_POST['submit'])) {
    			  $title = trim_string($_POST['namn']);
    			  $efternamn = trim_string($_POST['efternamn']);	
    			  $adress = trim_string($_POST['adress']);
    			  $telefonnr = trim_string($_POST['telefonnr']);
    			  $kontakt = trim_string($_POST['kontakt']);	
    			$query = "INSERT INTO arbetsgivare SET namn='$namn', efternamn='$efternamn', 
    			  adress='$adress' telefonnr='$telefonnr' kontakt='$kontakt'";
    			$result = mysql_query($query);
    			if ($result) {
    			  print "<p>Skrivningen till databasen lyckades!</p>";
    			header('Location: arbetsgivare_inskriven.php');
    			else {
    			  print "<p>Skrivningen till databasen misslyckades!</p>";	
    		<div class="clear"></div>
    	<div id="footer">
    		<p>&copy; 2008 Sajt. Design: <a href="#" title="Christos Webmaster">christos webmaster</a> ddd eee <a href="#" title="eeee">eeee</a>. Valid <a href="http://validator.w3.org/check/referer" title="valid XHTML strict">XHTML</a> and <a href="http://jigsaw.w3.org/css-validator/check/referer" title="CSS">CSS</a></p>
    <? ob_flush(); ?>
    Why does it not WRITE the registration to my database? It just forwards me to index.php as it is written, but no registration is made to the database.
    It is registration script with error when having written for example the password wrong and email.
    Last edited by Baxxter; 06-13-2012 at 04:49 AM.

  2. #2
    Join Date
    Jun 2010
    "bug" fixed .

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center