- This topic is empty.
-
AuthorPosts
-
July 12, 2010 at 5:35 pm #29608
allampatu
Participanthi guys
i have this script to allow user registration with activation link. all data goes in a database.the script works fine but when i add an user in my DB i see two records, the first one with the right data and the second one with a blank record.
if i don’t delete this record i can’t add more users, in my web page compare Error: Duplicate entry ” for key 2this is the code that going me crazy
Code:thanks for your help guys
July 13, 2010 at 11:38 am #79708allampatu
Participanti’ve tried every solution on comments but i can’t still figure out
July 14, 2010 at 2:36 am #79728vijaywebmaker
MemberI have just give you the sample coding format, It will be very useful for you
Code for Textbox
<input type="text" value="" name="sample" size="15"/>Code for Posting the value
$sample = $_POST;Code for Inserting the values in the database
$sql = "INSERT INTO profile(image)" .
"VALUES(‘".$image."’) ";
mysql_db_query($db, $sql);Please assign all the values like this, now the values will insert the database only one time…
July 15, 2010 at 11:36 am #79817allampatu
Participanti’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"> </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"> </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]
July 16, 2010 at 5:19 am #79856Tcooper
MemberInstead of returning ‘error’ when it fails, check mysql_error() – that way you can actually see why it’s failing.
July 16, 2010 at 9:31 am #79865allampatu
Participantok now i know a new command!
i wrote mysql_query($query) or die (mysql_error())
and i get this error, Unknown column ‘ID’ in ‘field list’
where am i wrong?
July 16, 2010 at 9:34 am #79866Rob MacKay
Participantyou are probably calling your ID column in upper case and the col name is actually in lower case. It is something like that. Else the ID col dosen’t exist at all
July 18, 2010 at 6:49 am #79897allampatu
Participant"Robskiwarrior" wrote:you are probably calling your ID column in upper case and the col name is actually in lower case. It is something like that. Else the ID col dosen’t exist at allyou got it dude!
now my form with activation email works pretty well.
now i’ve added with the help of dreamweaver cs4 the spry validation field and it works fine too.
my last question is, could a form with required field and activation email avoid spam?
i must to embed a captcha field?
thanks
July 26, 2010 at 4:29 am #80377allampatu
Participanti would like embed a captcha sistem. it works but the required fields are like not required, so if complete only the captcha the form sent data with blank field.
I tried two different (reCAPTCHA google and another) but both have the same result.solution at this point that I could invent?
August 10, 2012 at 12:18 pm #107692nsunh96
MemberThe form works perfectly! I implemented this into a popup. However, once the person hits submit, they get the generic text “An email has been sent to THEIR EMAIL with an activation key. Please check your mail to complete registration.” I created a nice looking success page to replace this, but I don’t know how to code it in the PHP. Help!
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.