Another Php Quiz For Beginners Only!

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 24, 2009, 10:43 PM
432107 members and 299081 Topics
Latest Member: lil_mama
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Webmasters (Moderators: OmniPotens, yawa-ti-de)  |  Another Php Quiz For Beginners Only!
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Another Php Quiz For Beginners Only!  (Read 119 views)
*dhtml
Another Php Quiz For Beginners Only!
« on: September 15, 2009, 10:10 PM »

Now you have a MySQL table with only one field - formData
database - >table
structure - formData [LongText]

form 1
username
password

form 2
firstname
lastname
email

form3
contact address
message text

So i have drawn out like 3 different forms.
Now how will you write a single php script that can submit any of the form data into that table and hold
all the values for future purposes. Dont bother yourself with retrieval (that is slightly advanced)

Lemme attempt to clarify
so in form 1, you say action="send.php"
and you repeat the same in form2 and form3

So that no matter the number of fields, the script can submit them into a single row in the 1 X 1 table!
If i am not making sense, please ask o!

quadrillio (m)
Re: Another Php Quiz For Beginners Only!
« #1 on: September 16, 2009, 12:21 PM »

it's seem No beginner in d house can dare an attempt, maybe average coder, should be added.

b4 pros go begin take annoyance answer d question, LOL.

patiently waiting.

SAFE
biggjoe (m)
Re: Another Php Quiz For Beginners Only!
« #2 on: September 17, 2009, 02:17 PM »

This question has been open since yesterday and yet no one seems to be willing to respond.

Reasons for that could be that:

1. people are afraid of being termed a 'beginner' if they answer it.
2.the question  might not be completely clear
3.people dont just know the answer  Grin

In my own case, I will attempt to answer it, beginner or no beginner BUT the question is not completely clear to me .

@dhtml,
1. are you asking us to write a script that submits all the form fields into one DB field?
2. if so, do you expect the data submitted to be separated by anything (space or comma)?
yawa-ti-de (f)
Re: Another Php Quiz For Beginners Only!
« #3 on: September 17, 2009, 02:41 PM »

biggjoe:

I think if you did a poll, most people would probably go for #2 Wink

I have been scratching my head since the quiz went up and haven't asked for clarification cos I don't even know what to ask clarification for  Cool
nitation (m)
Re: Another Php Quiz For Beginners Only!
« #4 on: September 17, 2009, 04:31 PM »

@ yawatide

I think that should be it, but you never can tell with DHTML. Maybe we must use the framework to achieve this. Bros come and answer us ooo! This question is kicking my butt

- nitation
*dhtml
Re: Another Php Quiz For Beginners Only!
« #5 on: September 17, 2009, 08:50 PM »

has nothing to do with my framework really. . .they key is serializing data in php http://www.php.net/serialize
You can just serialize the entire post array into a single variable. . . .in short, the submission script will be something like this:

submit.php
Quote
<?php
$val=mysql_real_escape_string(serialize($_POST));
mysql_query("insert into jos_register(raw) values('$val',curdate(),curtime()) ") or die(mysql_error());
?>
That is a sample submission script copied directly from a past project, just remove the curdate and time to get the direct solution to the quiz.

Serializing is the means by which sessions are stored whether in files or database. No matter the number of session data you store, they will
be stored using serialize and decoded during serialization. Serialization is a very old programming technique you find in all self-respecting programming languages from c++,java. . . .
biggjoe (m)
Re: Another Php Quiz For Beginners Only!
« #6 on: September 18, 2009, 07:56 AM »

Quote from: *dhtml on September 17, 2009, 08:50 PM
has nothing to do with my framework really. . .they key is serializing data in php http://www.php.net/serialize
You can just serialize the entire post array into a single variable. . . .in short, the submission script will be something like this:

submit.phpThat is a sample submission script copied directly from a past project, just remove the curdate and time to get the direct solution to the quiz.

Serializing is the means by which sessions are stored whether in files or database. No matter the number of session data you store, they will
be stored using serialize and decoded during serialization. Serialization is a very old programming technique you find in all self-respecting programming languages from c++,java. . . .

Now at least we know what you want us to do.
The way I would have done it is by concatenating all the POST variables into a single variable. That was why I asked do u want the fields separated by anything (comma or space.)
Before you said it, I didnt even know about  serialization.

Below is how I intended to do it.

To insert username, password and firstname into table - 'dtable' with field 'formData'
Quote
<?php
// I'll declare all the variables first (not 4getting to escape all escapables  Wink).
$user = $_POST['username'];
$pass= $_POST['password'];
$fname = $_POST['firstname'];

// then combine them all. Of course, anything (space or comma) can be in between if required.
$var =$user.$pass.$fname;

// then I will insert $var into  dtable
mysql_query("INSERT INTO dtable (formData) VALUES('$var')") or die(mysql_error());
?>
lojik (m)
Re: Another Php Quiz For Beginners Only!
« #7 on: September 19, 2009, 08:01 PM »

@dhtml
aint heard of serialize b4.
Seriously speaking, if u say this is for beginners only, then i guess i shd be called an aspiring beginner.  Grin.

How u dey bros. I still dey boot o. i go holla u wen i don login.
*dhtml
Re: Another Php Quiz For Beginners Only!
« #8 on: September 20, 2009, 07:50 AM »

ok, my mistake, but i was thinking serialization is beginners stuff. O well, anyway, it is quite trivial anyway. Just like we have json_encode/json_decode, escape/unescape,urlencode/urldecode. . . .so we have serialize/unserialize
Lojik, dont worry, my framework is ready to do some work, i have already used it on 3 websites already and they are working fine. but i am still doing some evaluation, but it works as it should.
 We Do Your Working Website  Microsoft Gives Yahoo Deadline On Offer  Much Touted Search Engine Fails To Impress On Debut  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.