Jump to content

need help in my dynamic input


pixeltrace

Recommended Posts

hi,

 

i have a test page and you can access it here

http://www.sinagtala.net/test.html

 

i will be using this to input names and emails in my database

which will be used for the newsletter sending.

 

my problem now is, i dont know how to create the insert sql query for this function

like how to do it in an array depending on how many items i will be adding.

 

example, i input 10 items

how will i code my sql insert query to automatically insert 10 items in my DB table

 

below is my current code for the form

<!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>Untitled Document</title>
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function createForm(number) {
data = "";    
inter = "'";
if (number < 16 && number > -1) {
for (i=1; i <= number; i++) {
if (i < 10) spaces="      ";
else spaces="    ";
data = data + "Name " + i + " :" + spaces
+ "<input type='text' size=10 name=" + inter
+ "name" + i + inter + "'>   "
+ "Email " + i + " :" + spaces
+ "<input type='text' size=10 name=" + inter
+ "email" + i + inter + "'><br>";
}
if (document.layers) {
document.layers.cust.document.write(data);
document.layers.cust.document.close();
}
else {
if (document.all) {
cust.innerHTML = data;
      }
   }
}
else {
window.alert("Please select up to 15 entries.");
   }
}

//  End -->
</script>

</head>

<body>
<center>
<form name=counter>
Number of items to enter:
  <input type=text name=number size=5>
<input type=button value="Update" onClick="createForm(counter.number.value);">
</form>

<br>

<form name="webform">
<table border=0>

<tr><td colspan=2>

<!-- Placeholder for dynamic form contents -->
<span id=cust style="position:relative;"></span>

</td>
</tr>
<tr>
<td></td>
<td><input type=submit value="Send"></td>
</tr>
</table>
</form>
</center>

<p><center>
</center><p>
</body>
</html>

 

hope you could help me with this.

thanks!

Link to comment
https://forums.phpfreaks.com/topic/71223-need-help-in-my-dynamic-input/
Share on other sites

<?php
$email = $_POST['email']; // don't forget to clean it
foreach($email as $k=>$v) {
// run query
}
?>
<form name="signup" id="signup" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input name="email[]" (name them this and do whatever you do to replicate them)
</form>

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.