Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 102

bfoutty
Code is Art
Profile
Posts: 185
Reg: Jun 12, 2011
Youngstown, OH
12,650
12/10/13 04:47 PM (11 years ago)

php script for Webform Generator plugin

I am using Chris1's web form generator plugin to create a form for a ed tech seminar at which I am presenting that will gather the attendees name, email, and school. I do not have an extensive background in php and am wondering if the following script will work to get the data into mysql database: <?php if(isset($_GET['submit'])){ $name = $_GET['name']; $email = $_GET['email']; $school = $_GET['school']; $conn = mysql_connect("mysql", "*****", "*****"); if(!$conn) { die('Could not connect: ' . mysql_error()); } mysql_select_db("whatevername_users"); $sql = "INSERT INTO registration(number, name, email, school) VALUES (null, '$name', '$email','$school')"; if (!mysql_query($sql,$conn)) { die('Error: ' . mysql_error()); } } ?>
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
12/10/13 05:14 PM (11 years ago)
Assuming you set your connection up right and your "registration" table has those columns, it should work - with one exception. You need to change the $_GET references to $_POST.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
12/10/13 06:19 PM (11 years ago)
I concur with Chris1 (any sane person would), but I'd add a little 'success' echo at the end of it, just to provide you with some feedback that it worked (or not). <?php if(isset($_POST['submit'])){ $name = $_POST['name']; $email = $_POST['email']; $school = $_POST['school']; $conn = mysql_connect("mysql", "*****", "*****"); if(!$conn) { die('Could not connect: ' . mysql_error()); } mysql_select_db("whatevername_users"); $sql = "INSERT INTO registration(number, name, email, school) VALUES (null, '$name', '$email','$school')"; if (!mysql_query($sql,$conn)) { die('Error: ' . mysql_error()); } else { echo('success!'); } ?> Cheers! -- Smug
 
bfoutty
Code is Art
Profile
Posts: 185
Reg: Jun 12, 2011
Youngstown, OH
12,650
like
12/10/13 06:24 PM (11 years ago)
Got it. Chris1:Thanks for responding so quickly. I am just starting to set this up for a presentation David B. and I are doing in San Diego in the beginning of February. This will look much better than embedding a Google form into a UIWebView. Thanks for all of your hard work in creating this plugin. Smug: Great addition. Thanks for your help.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
12/13/13 10:48 PM (11 years ago)
Sweet -- let us know when we can get a peek at the presentation. -- Niraj
 
bfoutty
Code is Art
Profile
Posts: 185
Reg: Jun 12, 2011
Youngstown, OH
12,650
like
12/14/13 06:07 AM (11 years ago)
Niraj, There won't be many Keynote slides for the presentation (probably only 2 or 3) as it will be a working session where we will actually go through the steps and create a simple app on the simulator. However, I am creating an iTunes U course that will accompany the presentation so that the attendees can go back and review it (this is what I was referring to when I contacted you about using your Push Notification tutorial). It will be a private course. So when I get it done I will post the enroll code to this conversation strand. Brian
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.