Jump to content

How to send multiple data in to the database using a single button


Kunkka

Recommended Posts

how to send multiple data in to the database using a single button. it has 10 fields but if a person enters only 7 fields it should go to without saving other 3 fields as NULL

 

here is the code.. pls help

 

<?php

 

session_start();

 

if(isset($_POST['register']))

{

 

require($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");

$connection= mysql_connect($db_host,$db_user,$db_password) or die("Error Connecting");

 

mysql_select_db($db_name,$connection);

 

 

if(isset($_POST['Email']))

{$email1 = $_POST['Email'];

$count+=1;}

else

{die("Please Enter the Student Email");

echo "$count";

}

 

if(isset($_POST['Email']))

{$email2 = $_POST['Email'];

$count+=1;}

else

{die("Please Enter the Student Email");}

 

if(isset($_POST['Email']))

{$email3 = $_POST['Email'];

$count+=1;}

else

{die("Please Enter the Student Email");}

 

if(isset($_POST['Email']))

{$email4 = $_POST['Email'];

$count+=1;}

else

{die("Please Enter the Student Email");}

 

if(isset($_POST['Email']))

{$email5 = $_POST['Email'];

$count+=1;}

else

{die("Please Enter the Student Email");}

 

if(isset($_POST['Email']))

{$email6 = $_POST['Email'];

$count+=1;}

else

{die("Please Enter the Student Email");}

 

if(isset($_POST['Email']))

{$email7 = $_POST['Email'];

$count+=1;}

else

{die("Please Enter the Student Email");}

 

if(isset($_POST['Email']))

{$email8 = $_POST['Email'];

$count+=1;}

else

{die("Please Enter the Student Email");}

 

if(isset($_POST['Email']))

{$email9 = $_POST['Email'];

$count+=1;}

else

{die("Please Enter the Student Email");}

 

if(isset($_POST['Email']))

{$email10 = $_POST['Email'];

$count+=1;}

else

{die("Please Enter the Student Email");}

 

 

echo "$count";

$query="INSERT INTO student (Email) VALUES ('$email1')";

 

mysql_query($query,$connection) or die (mysql_error()) ;

 

}

/*

else if($_POST['Email'] !== "online")

{

    echo "Sorry you are not a valid Lecturer";

 

}

else

{

echo "You have something incorrect here - you suck.";

    header("Location: register.php");

    exit;

}

  }

*/

?>

 

 

<html>

<head>

<title>Student Registration </title>

<link rel="stylesheet" type="text/css" href="css/stylemaster.css" />

</head>

 

<body>

 

<div id="page-container">

<div id="header" class="hidden"><h1> </h1>

  </div>

        <div id="main-nav" class="hidden">Main Nav</div>

  <div id="sidebar-a">

 

</div>

        <div id="content">

 

 

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" name="regForm" >

 

 

  <h2> Quick Registration Form  </h2>

  <h4>Register upto 10 Students at once</h4>

  <label>

  <table width="600" border="0" cellspacing="10" cellpadding="5">

  <tr>

    <td>Student Email: </td>

    <td><input type="text" name="std_email1" id="stdemail" size="30px"></td>

  </tr></table>

<hr color="#000066" size="5" width="90%">

  <table width="600" border="0" cellspacing="10" cellpadding="5">

  <tr>

    <td>Student Email: </td>

    <td><input type="text" name="std_email2" id="stdemail" size="30px"></td>

  </tr></table>

 

    <label>  </label>

    <hr color="#000066" size="5" width="90%">

    <label>    </label>

    <table width="600" border="0" cellspacing="10" cellpadding="5">

      <tr>

        <td>Student Email: </td>

        <td><input type="text" name="stdemail3" id="stdemail2" size="30px"></td>

      </tr>

    </table>

    <hr color="#000066" size="5" width="90%">

 

    <table width="600" border="0" cellspacing="10" cellpadding="5">

      <tr>

        <td>Student Email: </td>

        <td><input type="text" name="stdemail4" id="stdemail3" size="30px"></td>

      </tr>

    </table>

    <hr color="#000066" size="5" width="90%">

   

    <table width="600" border="0" cellspacing="10" cellpadding="5">

      <tr>

        <td>Student Email: </td>

        <td><input type="text" name="stdemail5" id="stdemail4" size="30px"></td>

      </tr>

    </table>

    <hr color="#000066" size="5" width="90%">

    <table width="600" border="0" cellspacing="10" cellpadding="5">

      <tr>

        <td>Student Email: </td>

        <td><input type="text" name="stdemail6" id="stdemail5" size="30px"></td>

      </tr>

    </table>

    <hr color="#000066" size="5" width="90%">

    <table width="600" border="0" cellspacing="10" cellpadding="5">

      <tr>

        <td>Student Email: </td>

        <td><input type="text" name="stdemail7" id="stdemail6" size="30px"></td>

      </tr>

    </table>

    <hr color="#000066" size="5" width="90%">

    <table width="600" border="0" cellspacing="10" cellpadding="5">

      <tr>

        <td>Student Email: </td>

        <td><input type="text" name="stdemail8" id="stdemail7" size="30px"></td>

      </tr>

    </table>

    <hr color="#000066" size="5" width="90%">

    <table width="600" border="0" cellspacing="10" cellpadding="5">

      <tr>

        <td>Student Email: </td>

        <td><input type="text" name="stdemail9" id="stdemail8" size="30px"></td>

      </tr>

    </table>

    <hr color="#000066" size="5" width="90%">

    <table width="600" border="0" cellspacing="10" cellpadding="5">

      <tr>

        <td>Student Email: </td>

        <td><input type="text" name="stdemail10" id="stdemail9" size="30px"></td>

      </tr>

    </table>

      <p> </p>

      <p>

        <label>

          <input type="submit" value="Submit" id="Submit" name="register">     

        </label>

        </p>

      </p>

    <pre align="left"> </pre>

    <p align="left"> </p>

  <p>   </p>

</form>

</div>

</body>

 

</html>

   

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.