Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,846 members, 7,820,949 topics. Date: Wednesday, 08 May 2024 at 04:40 AM

Another Php Quiz For Beginners Only! - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Another Php Quiz For Beginners Only! (1239 Views)

Blogging Advice For Beginners / Most Confusing And Simple Maths Quiz / Designing A Website: For Beginners (2) (3) (4)

(1) (Reply) (Go Down)

Another Php Quiz For Beginners Only! by Nobody: 10:10pm On Sep 15, 2009
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!
Re: Another Php Quiz For Beginners Only! by quadrillio(m): 12:21pm On Sep 16, 2009
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
Re: Another Php Quiz For Beginners Only! by biggjoe(m): 2:17pm On Sep 17, 2009
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)?
Re: Another Php Quiz For Beginners Only! by yawatide(f): 2:41pm On Sep 17, 2009
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
Re: Another Php Quiz For Beginners Only! by nitation(m): 4:31pm On Sep 17, 2009
@ 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
Re: Another Php Quiz For Beginners Only! by Nobody: 8:50pm On Sep 17, 2009
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
<?php
$val=mysql_real_escape_string(serialize($_POST));
mysql_query("insert into jos_register(raw) values('$val',curdate(),curtime()) "wink 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. . . .
Re: Another Php Quiz For Beginners Only! by biggjoe(m): 7:56am On Sep 18, 2009
*dhtml:

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'
<?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')"wink or die(mysql_error());
?>
Re: Another Php Quiz For Beginners Only! by lojik(m): 8:01pm On Sep 19, 2009
@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.
Re: Another Php Quiz For Beginners Only! by Nobody: 7:50am On Sep 20, 2009
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.

(1) (Reply)

/ Nigerian Web Hosting Company Using Softaculous Script Auto Installer ? / Rocking Nigerian Online Forums - Where Are They?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 19
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.