...

View Full Version : need help creating simpl php comment page



slade powers
12-15-2010, 05:27 AM
hello all: hope i am in the right place.
i am looking to build a comment type page on
our church website. i suppose it would be
similar to the one the comment section
on you tube. in all actuality it is a
testimony page where they may post
what is good in their lives.
i have some code written
but i'm not very good at it...just learning.
i have run across some very elaborate free
comment editors but they are too much for
our needs.
basically, all we need is a very simple script
that will reflect whatever the user inputs
into the text area of the form allowing us to
edit as needed.

here is our html code:

<form id="testify" name="testify" method="post" action="testify.php">
<h4>
<textarea name="testimony" id="testimony" cols="45" rows="5"></textarea>
</h4>
</form>
<p>
<input type="submit" name="button2" id="button2" value="Testify Now" />
</p>
</div>
</div>

from here we get kinda stuck. We appreciate any help that may be available.
Thank You.

Fumigator
12-15-2010, 06:06 AM
Divide the task into chunks.

Chunk 1: User enters data into an HTML form and submits.

Chunk 2: Data is saved into a file or database table.

Chunk 3: Data is displayed.

Take it one chunk at a time.

Now a kind note: You are going to be spammed into the ground by spammers if you do not have some kind of approval mechanism in place. If you do nothing but kick back to the page whatever is entered in the form, you'll have hundreds of Viagra and ***** enlargement posts overnight. Just a friendly warning.

slade powers
12-15-2010, 06:51 AM
here we have attempted to put php script in an html doc so that it will
display in the text area hopefully after the text has been entered by the user:

<form id="testify" name="testify" method="post" action="testify.php">
<h4>
<textarea name="testify" id="testify" cols="45" rows="5"></textarea>
</h4>
</form>
<p>
<input type="submit" name="button2" id="button2" value="Testify Now" />
</p>
</div>
</div>


testify.php:

<html>
<body>

Welcome
<?php echo $_POST["testify"]; ?>!<br />


</body>
</html>

Fumigator
12-15-2010, 04:40 PM
How did that work out for ya?

You want to be careful to keep your HTML valid. The "id" attribute should be unique throughout your page and you have two elements with an id of "testify".

slade powers
12-17-2010, 06:59 PM
i so apologize for not responding sooner. my kid got sick and it's been a mess. thank
you for your patience.
I've changed the id to "testimony", so as to make sure the id is unique throughout the page. again i apologize and hope you will still help us.




<form id="testimony" name="testify" method="post" action="testify.php">
<h4>
<textarea name="testify" id="testify" cols="45" rows="5"></textarea>
</h4>
</form>
<p>
<input type="submit" name="button2" id="button2" value="Testify Now" />
</p>
</div>
</div>


<html>
<body>


<?php echo $_POST["testify"]; ?>!<br />


</body>
</html>

its good that i learned to keep the id name attribute separate from the other names in the form. thanks.

adarshakb
12-17-2010, 07:23 PM
You need to establish an sql connection if you want to store in database



function GET_CONNECTION($host,$account,$password,$db)
{
$err=NULL;
$c = @ new mysqli($host,$account,$password,$db);
if (mysqli_connect_errno() != 0) { // // get the text of the error message from MySQLi //
$err = mysqli_connect_error();$err.= "\nConection to database failed!<br />"; }
if($err!=NULL)
throw new Exception($err);

return $c;
}



Then you may need to escape string with php to put it in database



mysql_escape_string($string);


Also you need a database table to store the testimonials

slade powers
12-19-2010, 09:23 PM
thank you...i'm beginning to work on it now. i'm currently setting up the database in myphpadmin. back very soon.

mlseim
12-19-2010, 09:49 PM
Is someone going to administer the comments before they are posted?
I hate to think this would happen, but you're going to end-up with comments
your church will not want on their website ... and who is going to be the judge
of what comments are accepted and which one's are not?
I personally think it's a bad idea.

The only reason I would say to go ahead and do this project, would be so you
could learn more about PHP and MySQL. The experience will be more beneficial
than the result.

slade powers
12-22-2010, 03:21 AM
i regret to inform that the church has decided to hire someone to do the backend. i am disappointed that i was not able to see this through to completion. However, i am working on a personal site and need php/myphpadmin assistance in accessing form data so i can use it.

here is the html created in cs4:


<legend>Parents Contact Information</legend>
</h3>
<form id="form1" name="form1" method="POST" action="babiesnmovies.php">
<p>
<label for="babiesnmovies.com/register">Your First Name</label>
<input type="text" name="yourfirstname" id="babiesnmovies.com/register" />
<label for="babiesnmovies.com/registered"><br />
Your Last Name</label>
<input type="text" name="yourlastname" id="babiesnmovies.com/registered" />
</p>
<p>
<label for="babiesnmovies.com/yourname">Your Phone Number</label>
<input type="text" name="yourphonenumber" id="babiesnmovies.com/yourname" />
<label for="babiesnmovies.com/email"><br />
Your E-mail</label>
<input type="text" name="youremail" id="babiesnmovies.com/email" />
</p>
</p>
<p>&nbsp;</p>
<h3>
<legend>Baby's Vitals</legend>
</h3>
<p>
<label for="babiesnmovies.com/baby'slast">Baby's First Name</label>
<input type="text" name="babysfirstname" id="babiesnmovies.com/baby'sfirst" />
<label for="babiesnmovies.com/babies">Baby's Middle Name</label>
<input type="text" name="babysmiddlename" id="babiesnmovies.com/babies" />
</p>
<p>
<label for="babyslastname">Baby's Last Name</label>
<input type="text" name="babyslastname" id="babyslastname" />
</p>
<p>
<label for="babiesnmovies.com/babybday">Baby's Birthdate</label>
<input type="text" name="babysbirthdate" id="babiesnmovies.com/babybday" />
<label for="babiesnmovies.com/babyage">Baby's Age</label>
<input type="text" name="babysage" id="babiesnmovies.com/babyage" />

</p>
<p>
<label for="babiesnmovies.com/baby">Baby's Height</label>
<input type="text" name="babysheight" id="babiesnmovies.com/baby" />
<label for="babiesnmovies.com/babyweight">Baby's Weight</label>
<input type="text" name="babysweight" id="babiesnmovies.com/babyweight" />
</p>
<p>
<label for="babiesnmovies.com/babyeyes">Baby's Eye Color</label>
<input type="text" name="babyseyecolor" id="babiesnmovies.com/babyeyes" />
<label for="babiesnmovies.com/babyhair">Baby's Hair Color</label>
<input type="text" name="babyshaircolor" id="babiesnmovies.com/babyhair" />
</p>
<p>
<label for="babiesnmovies.com/babyrace">Baby's Ethnicity</label>
<input type="text" name="babysethnicity" id="babiesnmovies.com/babyrace" />
</p>
<p><input name="formsubmit" type="submit" value="Submit" />
</form>



$yourfirstname = $_POST['YourFirstName'];
$yourlastname = $_POST['YourLastName'];
$yourphonenumber = $_POST['YourPhoneNumber'];
$youremailaddress = $_POST['YourE-mailAddress'];
$babysfirstname = $_POST['BabysFirstName'];
$babysmiddlename = $_POST['BabysMiddleName'];
$babyslastname = $_POST['BabysLastName'];
$babysbirthdate = $_POST['BabysBirthdate'];
$babysage = $_POST['BabysAge'];
$babysheight = $_POST['BabysHeight'];
$babysweight = $_POST['BabysWeight'];
$babyseyecolor = $_POST['BabysEyeColor'];
$babyshaircolor = $_POST['BabysHairColor'];
$babysethicity = $_POST['Babys Ethnicity'];


mysql_select_db("xxx", $con);
$sql="INSERT INTO register (Your First Name, Your Last Name, Your Phone Number, Your E-mail Address, Baby's First Name, Baby's Middle Name,
Baby's Last Name, Baby's Birthdate, Baby's Age, Baby's Height, Baby's Weight, Baby's Eye Color, Baby's Hair Color, Baby's Ethnicity) values ('$yourfirstname',
'$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname',
'$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')";

mysql_query($sql, $con) or die ("<br>Query string: $sql<br>Produced error: " . mysql_error() . '<br>');

?>

when i hit the submit button it appears that no data is sent to the server. i really would like as much help as possible. i want to learn this even if the church has taken a different path. i want this.

Thanks so very very much:).

mlseim
12-22-2010, 03:34 AM
Oh, I know why ....

your form variable names are all small case,
but on the processing script, you have mixed case variable names.

<input type="text" name="yourfirstname" id="babiesnmovies.com/register" />
$yourfirstname = $_POST['YourFirstName'];

... and all of them are like that.


.

slade powers
12-22-2010, 12:57 PM
thanks so much for the prompt response. it's so good to receive a little help from real coders.

i've implemented all the suggested changes and the script and code are as follows:


<legend>Parents Contact Information</legend>
</h3>
<form id="form1" name="form1" method="POST" action="Connections/babiesnmovies.php">
<p>
<label for="babiesnmovies.com/register">Your First Name</label>
<input type="text" name="YourFirstName" id="babiesnmovies.com/register" />
<label for="babiesnmovies.com/registered"><br />
Your Last Name</label>
<input type="text" name="YourLastName" id="babiesnmovies.com/registered" />
</p>
<p>
<label for="babiesnmovies.com/yourname">Your Phone Number</label>
<input type="text" name="YourPhoneNumber" id="babiesnmovies.com/yourname" />
<label for="babiesnmovies.com/email"><br />
Your E-mail</label>
<input type="text" name="YourE-mailAddress" id="babiesnmovies.com/email" />
</p>
</p>
<p>&nbsp;</p>
<h3>
<legend>Baby's Vitals</legend>
</h3>
<p>
<label for="babiesnmovies.com/baby'slast">Baby's First Name</label>
<input type="text" name="BabysFirstName" id="babiesnmovies.com/baby'sfirst" />
<label for="babiesnmovies.com/babies">Baby's Middle Name</label>
<input type="text" name="BabysMiddleName" id="babiesnmovies.com/babies" />
</p>
<p>
<label for="babyslastname">Baby's Last Name</label>
<input type="text" name="BabysLastName" id="babyslastname" />
</p>
<p>
<label for="babiesnmovies.com/babybday">Baby's Birthdate</label>
<input type="text" name="BabysBirthdate" id="babiesnmovies.com/babybday" />
<label for="babiesnmovies.com/babyage">Baby's Age</label>
<input type="text" name="BabysAge" id="babiesnmovies.com/babyage" />

</p>
<p>
<label for="babiesnmovies.com/baby">Baby's Height</label>
<input type="text" name="BabysHeight" id="babiesnmovies.com/baby" />
<label for="babiesnmovies.com/babyweight">Baby's Weight</label>
<input type="text" name="BabysWeight" id="babiesnmovies.com/babyweight" />
</p>
<p>
<label for="babiesnmovies.com/babyeyes">Baby's Eye Color</label>
<input type="text" name="BabysEyeColor" id="babiesnmovies.com/babyeyes" />
<label for="babiesnmovies.com/babyhair">Baby's Hair Color</label>
<input type="text" name="BabysHairColor" id="babiesnmovies.com/babyhair" />
</p>
<p>
<label for="babiesnmovies.com/babyrace">Baby's Ethnicity</label>
<input type="text" name="BabysEthnicity" id="babiesnmovies.com/babyrace" />
</p>
<p><input name="formsubmit" type="submit" value="Submit" />
</form>




$yourfirstname = $_POST['YourFirstName'];
$yourlastname = $_POST['YourLastName'];
$yourphonenumber = $_POST['YourPhoneNumber'];
$youremailaddress = $_POST['YourE-mailAddress'];
$babysfirstname = $_POST['BabysFirstName'];
$babysmiddlename = $_POST['BabysMiddleName'];
$babyslastname = $_POST['BabysLastName'];
$babysbirthdate = $_POST['BabysBirthdate'];
$babysage = $_POST['BabysAge'];
$babysheight = $_POST['BabysHeight'];
$babysweight = $_POST['BabysWeight'];
$babyseyecolor = $_POST['BabysEyeColor'];
$babyshaircolor = $_POST['BabysHairColor'];
$babysethicity = $_POST['BabysEthnicity'];


mysql_select_db("db337879506", $con);
$sql="INSERT INTO register (Your First Name, Your Last Name, Your Phone Number, Your E-mail Address, Baby's First Name, Baby's Middle Name,
Baby's Last Name, Baby's Birthdate, Baby's Age, Baby's Height, Baby's Weight, Baby's Eye Color, Baby's Hair Color, Baby's Ethnicity) values ('$yourfirstname',
'$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname',
'$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')";


mysql_query($sql, $con) or die ("<br>Query string: $sql<br>Produced error: " . mysql_error() . '<br>');

?>

i've also removed the
header( "Location: http://www.babiesnmovies.com/ThankU4Registering.html" );
from the script to see what happens when the form is submitted. it appears as if the header masked the exceptions...maybe because it was the code encountered first. anyway, this is the output when i submitted the form with random info:

Query string: INSERT INTO register (Your First Name, Your Last Name, Your Phone Number, Your E-mail Address, Baby's First Name, Baby's Middle Name, Baby's Last Name, Baby's Birthdate, Baby's Age, Baby's Height, Baby's Weight, Baby's Eye Color, Baby's Hair Color, Baby's Ethnicity) values ('SF', 'SDF', '', '', 'SDGF', 'SDF', 'SDF', 'SDF', '', '', '', 'SDF', 'SDF', '')
Produced error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'First Name, Your Last Name, Your Phone Number, Your E-mail Address, Baby's First' at line 1

i'm really lost now. any advice? thank you.

mlseim
12-22-2010, 01:27 PM
Now you're getting a MySQL error.

I question the use of spaces and especially single quotes you used for MySQL column names.

It's my opinion that you should change your variable name spaces to underscore,
and eliminate any special characters (like the single quote ... baby's ).

You would have to change all of those within your MySQL admin and also in the script.

slade powers
12-22-2010, 08:36 PM
:)

things are looking up! thanks. i followed your suggestions and it appears to be working:)

i removed the spaces, the hyphen in the email field/variable and rid myself of the spaces ( i did not include the underscore as you suggested...if that's alright:o). i did this for the html, php and myphpadmin fields


$yourfirstname = $_POST['YourFirstName'];
$yourlastname = $_POST['YourLastName'];
$yourphonenumber = $_POST['YourPhoneNumber'];
$youremailaddress = $_POST['YourEmailAddress'];
$babysfirstname = $_POST['BabysFirstName'];
$babysmiddlename = $_POST['BabysMiddleName'];
$babyslastname = $_POST['BabysLastName'];
$babysbirthdate = $_POST['BabysBirthdate'];
$babysage = $_POST['BabysAge'];
$babysheight = $_POST['BabysHeight'];
$babysweight = $_POST['BabysWeight'];
$babyseyecolor = $_POST['BabysEyeColor'];
$babyshaircolor = $_POST['BabysHairColor'];
$babysethicity = $_POST['BabysEthnicity'];


mysql_select_db("xxx", $con);
$sql="INSERT INTO register (YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName,
BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ('$yourfirstname',
'$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname',
'$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')";


mysql_query($sql, $con) or die ("<br>Query string: $sql<br>Produced error: " . mysql_error() . '<br>');

i haven't tested all the fields yet but i get no exception and i can see the data in my database table!!!!! so far this has been a total success.

i'm going to re-include that heading script in the which jumps to the checkbox form. is it just possible that you could walk me through the steps of setting up the php script of the form?


<form id="form1" name="form1" method="post" action="">
<table width="451">
<tr>
<td width="627"><h3>
<label>
<input type="checkbox" name="CheckboxGroup1" value="film" id="CheckboxGroup1_0" />
Film</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="CheckboxGroup1" value="television (cmmercials, movies)" id="CheckboxGroup1_1" />
Television (commercials/movies)</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="CheckboxGroup1" value="radio" id="CheckboxGroup1_2" />
Radio</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="CheckboxGroup1" value="magazines" id="CheckboxGroup1_3" />
Magazines</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="CheckboxGroup1" value="newspaper" id="CheckboxGroup1_4" />
Newspaper</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="CheckboxGroup1" value="catalogs" id="CheckboxGroup1_5" />
Catalogs</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="CheckboxGroup1" value="photography" id="CheckboxGroup1_6" />
Photograpy</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="CheckboxGroup1" value="web" id="CheckboxGroup1_7" />
Web</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="CheckboxGroup1" value="Fashion" id="CheckboxGroup1_8" />
Fashion</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="CheckboxGroup1" value="modeling" id="CheckboxGroup1_9" />
Modeling</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="CheckboxGroup1" value="sittings (for portraits)" id="CheckboxGroup1_10" />
Sittings (for portraits)</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="CheckboxGroup1" value="events" id="CheckboxGroup1_11" />
Events</label>
</h3></td>
</tr>
</table>
<div></div>
</form>

i have yet to set up a table and do the php for the form. and actually its a set of different forms over several pages. i know it seems like its too much; to do different forms on different pages but i'm looking to provide a different type of experience where filling in the form isn't so tedious; i'm trying to add a little more than just the form submitting.
but i know others need your help too! you're very valuable. if you couldn't help me any further you really did hook me up. thank you very very much.

Fumigator
12-22-2010, 09:21 PM
Multiple page forms can be pretty tricky... the trick is how to bring the data from each page over to the next page. You can save the data into a database, or use sessions... at any rate you'll have some good experience under your belt once you're done :thumbsup:

mlseim
12-22-2010, 09:23 PM
So let me get this straight ...

You are going to have several forms.
Between each form, you will save the information for that form before you display the next one?

That's a good plan, so the user doesn't have to start all over if they get halfway and
decide to quit (and come back later).

So, you already have the "username" field ... you will have to add a field where the
user can enter a "password" (enter it twice to validate).

By doing it that way, at the very beginning of each page (script) that has a form,
you will need to check to see if the user has already filled it out. Because you don't
know who is currently viewing your form, you will need to have some way for the user
to "login" ... to see if they already have their name in the database. If they have their
name in your database, that means they previously filled-out, at least, the first form.

You can then determine where they left-off, or quit the form(s). This will also be a way
to give the user a "user profile" page where they can modify, or correct any wrong
information.

==================

On post #13, you're now showing us a form with checkboxes.
is that the 2nd form that will appear for the user?

Are you questioning how to process the checkboxes?


EDIT:
There are some "security issues" you will need to address, in particular,
the use of "user input" being allowed to be used in a SQL query.
I just don't want to throw too many things at you, at one time.

Just know that any variable values provided by a user (site visitor) should be
sanitized if you plan on using it within a query. It will stop users from
injecting their own queries into your database.

The red part added to all user defined variables:

$yourfirstname = mysql_real_escape_string($_POST['YourFirstName']);
$yourlastname = mysql_real_escape_string($_POST['YourLastName']);

.
.
. etc.



.

slade powers
12-25-2010, 08:06 PM
thanks for the help...I swear.
i am with fam on this Christmas
I wish you & you'd all the best.
I look forward to all the challenges
of this new year & this php business.
Thanks again.

slade powers
12-30-2010, 06:12 AM
well i've returned. thanks for the support.
i am now trying to process the checkboxes. the following is the html i generated by cs4:


<form id="mediatype" name="mt" method="post" action="mt.php">
<table width="451">
<tr>
<td width="627"><h3>
<label>
<input type="checkbox" name="cinema" value="film" id="film" />
Film</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="tele" value="television (commercials, movies)" id="tv" />
Television (commercials/movies)</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="rad" value="radio" id="radio" />
Radio</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="mags" value="magazines" id="mag" />
Magazines</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="paper" value="newspaper" id="newsprint" />
Newspaper</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="cats" value="catalogs" id="cat" />
Catalogs</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="pictures" value="photography" id="photo" />
Photograpy</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="net" value="web" id="www" />
Web</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="clothes" value="Fashion" id="style" />
Fashion</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="glam" value="modeling" id="catwalk" />
Modeling</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="paint" value="sittings (for portraits)" id="sit" />
Sittings (for portraits)</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="event" value="events" id="happenings" />
Events</label>
</h3></td>
</tr>
</table>
<div></div>
</form>

i will need to create the script and db table.
but before i move into that should i first edit the script to include the escape string mentioned in the last post?
and if possible i'm really ready for a big chunck of learning the next step of creating the php code for the form.
for the sake of a clearer of understanding what it is i'm working on the site may be viewed at babiesnmovies.com.
sometimes i get nervous because it seems such a daunting task with so much to do but...i gotta learn. i'm also reading php for dummies but i'm still lost sometimes. regardless, i've gotta keep pluggin' away. thanks

slade powers
12-30-2010, 06:16 AM
can someone tell me how to post a thanks so that all the world can see the help i've recieved? it will also show others and all that i so appreciate the assistance. i noticed my profile showed now thanks and that's not true. i am very grateful for every response. i'd like to demonstrate that on my profile.

mlseim
12-30-2010, 01:30 PM
Give each one the same name ... but a different value ...

You will be creating a "checkbox array". So I picked the name "media[]"
The square brackets indicate the array function.

Example:


tr>
<td width="627"><h3>
<label>
<input type="checkbox" name="media[]" value="film" id="film" />
Film</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="media[]" value="television (commercials, movies)" id="tv" />
Television (commercials/movies)</label>
</h3></td>
</tr>
<tr>




Once you do that, repost your form ...
and I'll show you how to process those checkboxes.

slade powers
12-30-2010, 08:51 PM
i changed the name to include the array function as suggested and posted. the following is the new html as posted:


<form id="mediatype" name="mt" method="post" action="mt.php">
<table width="451">
<tr>
<td width="627"><h3>
<label>
<input type="checkbox" name="media[]" value="film" id="film" />
Film</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="media[]" value="television (commercials, movies)" id="tv" />
Television (commercials/movies)</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="media[]" value="radio" id="radio" />
Radio</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="media[]" value="magazines" id="mag" />
Magazines</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="media[]" value="newspaper" id="newsprint" />
Newspaper</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="media[]" value="catalogs" id="cat" />
Catalogs</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="media[]" value="photography" id="photo" />
Photograpy</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="media[]" value="web" id="www" />
Web</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="media[]" value="Fashion" id="style" />
Fashion</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="media[]" value="modeling" id="catwalk" />
Modeling</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="media[]" value="sittings (for portraits)" id="sit" />
Sittings (for portraits)</label>
</h3></td>
</tr>
<tr>
<td><h3>
<label>
<input type="checkbox" name="media[]" value="events" id="happenings" />
Events</label>
</h3></td>
</tr>
</table>
<div></div>
</form>

awaiting the knowledge to process these checkboxes. i am actually learning this stuff and i am taking notes as we go. thanks so much, peace.:thumbsup:

mlseim
12-30-2010, 09:57 PM
To read that form of checkboxes, you'll have code like this ...



<?php
$med=$_POST['media'];

foreach($med as $item){
echo $item."<br>";
}

?>



Instead of echoing it, like my example, you'll be saving in the database.
You can use my example to test your form ... see if it lists the items you check.


EDIT:
I looked at the website ...

Very odd submit buttons ... it's hard to figure it out.
You describe what to click on, but I wonder if people
will not know what to do. And if anyone is visually impaired,
or not very experienced with the internet, they certainly won't
be able to process your forms.

Perhaps you are trying to thwart spammers?
In that case, maybe you need to require a person to register first
using an email confirmation type of program (PHP/MySQL script).

Once registered, they can create their own profile however and
whenever they wish ... along with their own "baby portfolio".

In any case, I don't want this to come out the wrong way ... because
I know this is a very new learning experience for you ... the website
doesn't look very professional. I don't think that I would be very
willing to pay for the service by looking at your website.

Do some testing on your site. Ask strangers to register and see if they
can figure it out. I had a hard time, and I'm very adept at online stuff.

My other advice is to find a professional CSS template (free or paid), and
use that as the "base layout" for your website. Alternatively, Joomla or Drupal.

Your project involves money ... a service that may or may not produce results
for your clients (no guarantees). You have to have a rock-solid, 110% great-looking website
if you expect someone to send you money. It has to give the client high confidence.





.

slade powers
12-31-2010, 03:36 AM
hello again. i've heard everything you said and others have told me the same. my dad said it looked like a 3rd grader designed it (lol). this is just for me to get my feet wet. what i was trying to do with the submit buttons was add a little excitement to the form. most forms are boring and laborious...personally, i can't stand the average form's look and feel. i just wanted to spice it up. i do intend on changing the entire look of the entire site. i merely wanted to get the forms together. those php scripts wont change when i revamp. trying to get the heavy lifting out of the way.

please do not be concerned about giving me constructive criticism. you have assisted me so much that i know you're here to help...it's totally ok. give me all ya got! and you put it very solidly that no one will pay for a service, with or without a guarantee of results, if they have no confidence in the product or brand based on the look of the site. aptly put and i am an apt pupil. these things will change before long, for sure. now to the meat and potatoes.

when you stated, "Instead of echoing it, like my example, you'll be saving in the database.", do you mean to say that as opposed to the echo command i include the server info? i did just that in dreamweaver and put the file. mt.php is as such:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL
$hostname_babiesnmovies = "xxx";
$database_babiesnmovies = "xxx";
$username_babiesnmovies = "xxx";
$password_babiesnmovies = "xxx";
$con = mysql_pconnect($hostname_xxx, $username_xxx, $password_xxx) or trigger_error(mysql_error(),E_USER_ERROR);

$med=$_POST['media'];

foreach($med as $item){
echo $item."<br>";
}

mysql_query($sql, $con) or die ("<br>Query string: $sql<br>Produced error: " . mysql_error() . '<br>');
?>

this error message was given
"Query string:
Produced error: Query was empty"
will i replace echo insert, the table name, mysql field names, etc?

i'm a scrub at this and i'm sure i goofed but i will get it. thanks again. you're great and i am grateful. :thumbsup::thumbsup: that's 2thumbs up.

mlseim
12-31-2010, 04:50 AM
When you processed the first form, how did you save that data?

I can't remember if you have a MySQL table that is saving the data?

This part is going to be really hard to do using this forum, because I don't
have access to your MySQL database. No way to test anything on my end.

After each form is submitted, you need to save the data from the form
into a database ... that part is not visible to any of us ... only you have access to it.

slade powers
12-31-2010, 04:57 AM
my web hosting service has me using myphpadmin/mysql to access and edit my db.

slade powers
12-31-2010, 05:16 AM
this is how the last script posted:


<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL
$hostname_babiesnmovies = "xxx";
$database_babiesnmovies = "xxx";
$username_babiesnmovies = "xxx";
$password_babiesnmovies = "xxx";
$con = mysql_pconnect($hostname_xxx, $username_xxx, $password_xxx) or trigger_error(mysql_error(),E_USER_ERROR);


$yourfirstname = $_POST['YourFirstName'];
$yourlastname = $_POST['YourLastName'];
$yourphonenumber = $_POST['YourPhoneNumber'];
$youremailaddress = $_POST['YourEmailAddress'];
$babysfirstname = $_POST['BabysFirstName'];
$babysmiddlename = $_POST['BabysMiddleName'];
$babyslastname = $_POST['BabysLastName'];
$babysbirthdate = $_POST['BabysBirthdate'];
$babysage = $_POST['BabysAge'];
$babysheight = $_POST['BabysHeight'];
$babysweight = $_POST['BabysWeight'];
$babyseyecolor = $_POST['BabysEyeColor'];
$babyshaircolor = $_POST['BabysHairColor'];
$babysethicity = $_POST['BabysEthnicity'];


mysql_select_db("xxx", $con);
$sql="INSERT INTO register (YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName,
BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ('$yourfirstname',
'$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname',
'$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')";

header( "Location: http://www.babiesnmovies.com/ThankU4Registering.html" );

mysql_query($sql, $con) or die ("<br>Query string: $sql<br>Produced error: " . mysql_error() . '<br>');

?>
and it runs beautifully.

mlseim
12-31-2010, 07:15 PM
OK,

Now with the 2nd form processing, you have to also do the insert into the table.

There is one issue that needs to be addressed ...
After you process your first form, you have to remember who you are working with.
You can't process the 2nd or 3rd form without knowing who the person is.

So, on the process script for the 1st form, let's remember the user's email ...

This modified script:


<?php
session_start();

# FileName="Connection_php_mysql.htm"
# Type="MYSQL
$hostname_babiesnmovies = "xxx";
$database_babiesnmovies = "xxx";
$username_babiesnmovies = "xxx";
$password_babiesnmovies = "xxx";
$con = mysql_pconnect($hostname_xxx, $username_xxx, $password_xxx) or trigger_error(mysql_error(),E_USER_ERROR);


$yourfirstname = $_POST['YourFirstName'];
$yourlastname = $_POST['YourLastName'];
$yourphonenumber = $_POST['YourPhoneNumber'];
$youremailaddress = $_POST['YourEmailAddress'];
$babysfirstname = $_POST['BabysFirstName'];
$babysmiddlename = $_POST['BabysMiddleName'];
$babyslastname = $_POST['BabysLastName'];
$babysbirthdate = $_POST['BabysBirthdate'];
$babysage = $_POST['BabysAge'];
$babysheight = $_POST['BabysHeight'];
$babysweight = $_POST['BabysWeight'];
$babyseyecolor = $_POST['BabysEyeColor'];
$babyshaircolor = $_POST['BabysHairColor'];
$babysethicity = $_POST['BabysEthnicity'];


mysql_select_db("xxx", $con);
$sql="INSERT INTO register (YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName,
BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ('$yourfirstname',
'$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname',
'$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')";

// Save their email address in a SESSION
$_SESSION['user']=$youremailaddress;

// You'll want to redirect to the next form ... instead of thank you.
header( "Location: http://www.babiesnmovies.com/ThankU4Registering.html" );

mysql_query($sql, $con) or die ("<br>Query string: $sql<br>Produced error: " . mysql_error() . '<br>');

?>



Now, on the 2nd form processing, you read the PHP session to see who they are.
You'll find out their email address.

PHP SESSION only lasts while their browser is open, so if they close their browser
and go to the 2nd form, you won't know who they are. Since you don't have a
log-in form, anyone who enters your forms 1/2-way through won't be able to register.


Here is more about the 2nd form processing:


<?php
session_start();

// find out their email address
$useremail=$_SESSION['user'];

# FileName="Connection_php_mysql.htm"
# Type="MYSQL
$hostname_babiesnmovies = "xxx";
$database_babiesnmovies = "xxx";
$username_babiesnmovies = "xxx";
$password_babiesnmovies = "xxx";
$con = mysql_pconnect($hostname_xxx, $username_xxx, $password_xxx) or trigger_error(mysql_error(),E_USER_ERROR);

$med=$_POST['media'];

foreach($med as $item){
echo $item."<br>";

// insert data into the table ... where YourEmailAddress = '$useremail'

// I'm not sure how you arranged your columns, but you'll have to
// determine which column to insert the checkbox.

}

mysql_query($sql, $con) or die ("<br>Query string: $sql<br>Produced error: " . mysql_error() . '<br>');
?>

slade powers
12-31-2010, 09:34 PM
i've implemented all the changes and they post as follows:
script for form 1


<?php
session_start();

# FileName="Connection_php_mysql.htm"
# Type="MYSQL
$hostname_babiesnmovies = "xxx";
$database_babiesnmovies = "xxx";
$username_babiesnmovies = "xxx";
$password_babiesnmovies = "xxx";
$con = mysql_pconnect($hostname_xxx, $username_xxx, $password_xxx) or trigger_error(mysql_error(),E_USER_ERROR);


$yourfirstname = $_POST['YourFirstName'];
$yourlastname = $_POST['YourLastName'];
$yourphonenumber = $_POST['YourPhoneNumber'];
$youremailaddress = $_POST['YourEmailAddress'];
$babysfirstname = $_POST['BabysFirstName'];
$babysmiddlename = $_POST['BabysMiddleName'];
$babyslastname = $_POST['BabysLastName'];
$babysbirthdate = $_POST['BabysBirthdate'];
$babysage = $_POST['BabysAge'];
$babysheight = $_POST['BabysHeight'];
$babysweight = $_POST['BabysWeight'];
$babyseyecolor = $_POST['BabysEyeColor'];
$babyshaircolor = $_POST['BabysHairColor'];
$babysethicity = $_POST['BabysEthnicity'];


mysql_select_db("xxx", $con);
$sql="INSERT INTO register (YourFirstName, YourLastName, YourPhoneNumber, YourEmailAddress, BabysFirstName, BabysMiddleName,
BabysLastName, BabysBirthdate, BabysAge, BabysHeight, BabysWeight, BabysEyeColor, BabysHairColor, BabysEthnicity) values ('$yourfirstname',
'$yourlastname', '$yourphonenumber', '$youremailaddress', '$babysfirstname', '$babysmiddlename', '$babyslastname',
'$babysbirthdate', '$babysage', '$babysheight', '$babysweight', '$babyseyecolor', '$babyshaircolor', '$babysethnicity')";

$_SESSION['user']=$youremailaddress;

header( "Location: http://www.babiesnmovies.com/mediatype.html" );

mysql_query($sql, $con) or die ("<br>Query string: $sql<br>Produced error: " . mysql_error() . '<br>');

?>

script for form 2:


<?php
session_start();

$useremail=$_SESSION['user'];

# FileName="Connection_php_mysql.htm"
# Type="MYSQL
$hostname_babiesnmovies = "xxx";
$database_babiesnmovies = "xxx";
$username_babiesnmovies = "xxx";
$password_babiesnmovies = "xxx";
$con = mysql_pconnect($hostname_xxx, $username_xxx, $password_xxx) or trigger_error(mysql_error(),E_USER_ERROR);

$med=$_POST['media'];

foreach($med as $item){
echo $item."<br>";
}

mysql_query($sql, $con) or die ("<br>Query string: $sql<br>Produced error: " . mysql_error() . '<br>');
?>

i have yet to create the new table but the columns will be in the order as they appear in the form. i'm going into myphp admin to create the table. is that what you meant by you weren't sure how i had arranged my columns?

mlseim
12-31-2010, 11:12 PM
wait a minute ...

You have to be careful how you create tables ...

The database needs to be logical, and make sense.

Are you going to give each user a unique ID number of some kind?
How will you know which users are interested in which media?

The whole "database system" needs to be thought-out before you do anything.

And you have more forms to do after form #2?

==============

I keep going back to the first discussion about a "registration system".
It's my opinion that you should have a new user register ... the very first thing.
They simply submit their email address, username, and password. They confirm
themselves using their email. After that, they have to log-in to enter all of your
forms. If they don't log-in, they cannot view your forms.

With your system now, I have no idea how you are going to keep track of who is
filling out your forms. It's going to be a total mess ... and spammers will wreck it all.


.

slade powers
01-01-2011, 12:06 AM
my objective was to have separate tables for each form. it seemed to me that if a person filed out each form then i would know, based on the time the form was submitted, who was the user. not anticipating very many submissions at the first would make it really easy to sort things out and eventually build a better php/mysql situation. of course i didn't know any better.
i cannot argue with the teacher. you know infinitely more than i. it also seems that your more logical way would prevent me from having to go through this again. the main thing at this juncture is i didn't want to burn out the one who was assisting me. yet, your being so adamant has shown me the light. guide me, my Liege.
the entire process will end with a user being able to upload a very short video if they so choose. i wont waste your time...lets do it your way, registration system, et al.
Thank you. i do want to do this right.

mlseim
01-01-2011, 12:48 AM
Separate tables would be great ... as long as you know who is viewing the form(s).

Well ... the only problem left is the lack of being able to do much using this forum.
Here is a free PHP registration/login script: http://php-login-script.com/

In your case, it is going to take some customization to make it work for your site.

The good thing about it though ... is it allows anyone to register. They get an email
that confirms the registration, and it also uses Re-Captcha if you wish. There is then
an admin part for you to view users, and handle their accounts.

Once a registration/login system is in place, you can control everything the logged-in
user can fill-out .. the forms you are making for example. You will always know who
is logged-in. People not logged-in will not be able to fill out your forms.

I really like the basic "system" of how it works ... but to blend it into your site and
make everything look correct will take some customization. I just don't know where
you fall into the technical abilities of that. I hate to drag you into something that ends-
up being way out of control for you.

This forum is great for answering questions and troubleshooting problems, but it's not
good for tutorials, or teaching PHP/MySQL to someone. I wish you had a real person
that lives close to you, that you could turn to.

slade powers
01-01-2011, 02:50 AM
i so totally respect your position. again, i don't want to inundate you. i'm sure you've got lots to do yourself and your time is valuable. but if you can help me stitch the pieces together with any spare time you have i would be truely indebted to you. my technical abilities are as long as your patience. its true that the medium of this forum can only take me so far but i can follow instructions like nobody's business.
Regardless, you have already been a super great help. Thanks a ton and thanks for the registration link.

Fumigator
01-01-2011, 07:42 PM
My $.02 would be two things: 1) No one likes filling out tons of information, especially right off the bat. I haven't looked at your forms but you might want to take a close look at what data you're gathering on the initial contact with a potential client and maybe save some of that info for the second contact. And 2), while it's great for you as a seller to get people to register, it's a turn-off to users and if you can possibly trim your form down to a single form plus video submission, you can avoid requiring a registration and still get the vital contact info you need to continue the sales pitch.

slade powers
01-05-2011, 06:32 PM
forgive the delay in my response. it seems that i have some reworking of the site to do. i have decided this in light of all the good feedback i have received. i just didn't want anyone to think i got discouraged and decided to hang it up. so thank you all. i will be back soon asking for advice and suggestions soon....no doubt. give me a few days. i'm going to rework pages so that two forms sit on one page thereby reducing the number of pages for forms.
Peace, All.

slade powers
01-17-2011, 01:05 AM
well all...as prophiesized, spammers have hit my site with all types of crap. does anyone know what i can do? i know...better said, "I've learned" from this forum, that it is more than likely the regform i was working was the point of entry. "they told me so...". Lesson learned.
I am going to the url removal component of Google to delete all that bad press.

Any suggestions for an immediate halt of this situation?
Thank you.

mlseim
01-17-2011, 01:18 AM
You have to require a user registration, and they need to confirm it in their own email.

Spammers will still hire people to actually register and try to post, but you'll get much
less spamming than you have now. Re-captcha will help thwart some of the automatic robots
on the main registration page.

Create a very simple user registration (one easy form). Once they confirm their email,
they will each have their own "profile page", where they fill-in all of the other information
they need. They have to log-in to view, add, delete, edit their profile page.

slade powers
01-17-2011, 02:07 AM
could you tell me where i can get the script for this and how to install it?
Please.

slade powers
01-17-2011, 02:13 AM
and would you know of a way to delist that spam that is now attached to my url? i mean offensive material. i recently referenced my site to someone and did not know that the stuff was there....OMG. what can i do to get that crap out of cyberspace.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum