Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Email Activation For Registration Forms Re: Email Activation For Registration Forms

#79817
allampatu
Participant

i’ve opted to build it from myself, i want learn php!

now i can’t understand why i can’t insert data into database, mysql_query function give me always error.

so this is my form

Code:
<form class="form" action="verify.php" method="post">
<p>
<label>First name
<input type="text" name="firstname" id="firstname" />
</label>
</p>
<p>
<label>Last name
<input type="text" name="lastname" id="lastname" />
</label>
</p>
<p>
<label>Job Title
<input type="text" name="jobtitle" id="jobtitle" />
</label>
</p>
<p>
<label>Organization
<input name="organization" type="text" id="organization" cols="45" rows="5"></textarea>
</label>
</p>
<p>
<label>Describe your organization in 100 words<br />
<textarea name="describeorg" id="describeorg" cols="30" rows="5"></textarea>
</label>
</p>
<p>
<label>Who to meet at the conference<br />
<textarea name="meet" id="meet" cols="30" rows="5"></textarea>
</label>
</p>
<p>
<label>Email
<input type="text" name="email" id="email" />
</label>
</p>
<table width="497">
<tr>
<td width="162">&nbsp;</td>
<td width="299">accept to be audio/video recorded<br />
and participation to the event made public</td>
<td width="20" align="center"><input type="checkbox" name="accept" id="accept" /></td>
</tr>
</table>
</p>
<table width="496">
<tr>
<td width="270" rowspan="2" align="left">&nbsp;</td>
<td width="161" rowspan="2" align="left">need special assistance (e.g. wheelchair accessible)</td>
<td width="49" align="right">no <input type="radio" name="noassistance" value="no" id="RadioGroup1_0" /></td>
</tr>
<tr>
<td align="right">yes <input type="radio" name="yesassistant" value="yes" id="RadioGroup1_1" /></td>
</tr>
</table>
<p>
<label>
<input type="submit" name="submit" id="submit" value="Register" />
</label>
</p>
</form>

and my verify.php code

Code:
<?php
$firstname=$_POST[’firstname’];
$lastname=$_POST[’lastname’];
$jobtitle=$_POST[’jobtitle’];
$organization=$_POST[’organization’];
$describeorg=$_POST[’describeorg’];
$meet=$_POST[’meet’];
$email=$_POST[’email’];
$accept=$_POST[’accept’];
$noassistance=$_POST[’noassistance’];
$yesassistance=$_POST[’yesassistance’];

$username = "user";
$password = "pass";
$host = "localhost";
$database = "my_db";

$db = mysql_connect($host, $username, $password) or die("Errore durante la connessione al database");
mysql_select_db($database, $db) or die("Errore durante la selezione del database");

$query = "INSERT INTO participants ( ID, firstname, lastname, jobtitle, organization, describeorg, meet, email, accept, noassistance, yesassistance) VALUES (‘NULL’, ‘.$firstname’, ‘.$lastname’, ‘.$jobtitle’, ‘.$organization’, ‘.$describeorg’, ‘.$meet’, ‘.$email’, ‘.$accept’, ‘.$noassistance’, ‘.$yesassistance’)";

mysql_query($query, $db) or die (‘error’);

?>

and at least my query for table

Code:

— MySQL 4.1.22
— Thu, 15 Jul 2010 17:33:50 +0200

CREATE TABLE `participants` (
`ID` int(10) not null default ‘0’,
`firstname` varchar(20),
`lastname` varchar(20),
`jobtitle` varchar(20),
`organization` varchar(20),
`describeorg` varchar(100),
`meet` varchar(100),
`email` varchar(20),
`noassistance` char(2),
`yesassistance` char(2),
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

— [Table `participants` is empty]