PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I wanted to use a single cell but couldn't figure it out. The code above actually was a thought that I should push each one into its own cell. But that was giving me defined errors, which I haven't figure out. yet either.
How can I write the form and the php to insert into a mysql.
<?php
else:
// Process signup submission
dbConnect('db');
if ($_POST['newpersonalemail']=='' or $_POST['newfirstname']==''
or $_POST['newlastname']=='') {
error('One or more required fields were left blank.\\n'.
'Please fill them in and try again.');
}
// Check for existing user with the new id
$sql = "SELECT COUNT(*) FROM user WHERE userid = '$_POST[newpersonalemail]'";
$result = mysql_query($sql);
if (!$result) {
error('A database error occurred in processing your '.
'submission.\\nIf this error persists, please '.
'email');
}
if (mysql_result($result,0,0)>0) {
error('A user already exists with your chosen newpersonalemail.\\n'.
'Please try another.');
}
/*Concat Checkbox Values into One string separated by commas for Select*/
foreach ($newethnicity as $value){
$search=$search.",".$value;
}
/* Remove Leading comma*/
$searchit=substr($search,1);
$sql = "INSERT INTO user SET
userid = '$_POST[newpersonalemail]',
password = '$_POST[newpass]',
firstname = '$_POST[newfirstname]',
middlename = '$_POST[newmiddlename]',
lastname = '$_POST[newlastname]',
ethnicity = $search
";
if (!mysql_query($sql))
error('A database error occurred in processing your '.
'submission.\\nIf this error persists, please '.
'contact you@example.com.\\n' . mysql_error());
I am a little confused and trying to learn.
thanks