Welcome! Log In Create A New Profile

Advanced

Topic 4A

Posted by Anonymous User 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Re: Topic 4A
April 10, 2006 03:54PM
I still do not get it
this is my output starting with the data that is passed from the form, so I conclude thta the form works well.


Array ( [firstname] => Angus [lastname] => Stok [age] => 43 [choice] => Array ( [0] => Computing [1] => Science ) )


Thanks for responding to this survey Angus Stok

These are your favorite book categories:


Warning: Invalid argument supplied for foreach() in C:\FoxServ\www\StudentPHP\thankyou.php on line 16



My code is

<?php
print_r($_POST);

$title = "Thank-you";
include("header.php"winking smiley;

$firstname = $_POST[firstname];
$lastname = $_POST[lastname];
$age = $_POST[age];

echo "Thanks for responding to this survey $firstname $lastname";
echo "<br><br>";
echo "<b>These are your favorite book categories:</b>";
echo "<br><br>";

foreach ($choice as $category)
{
echo "$category <br>\n";
}
include ("footer.php"winking smiley;
?>


Re: Topic 4A
April 10, 2006 09:38PM
Hi Angus

try
foreach ($_POST["choice"] as $category)

seems to work now
Re: Topic 4A
April 11, 2006 08:00AM
Thank you Libby

I have completed this topic

I seem to be a little late, April does not have enough days.
Re: Topic 4A
April 11, 2006 02:11PM
Also completed. Angus, i agree with you - there just aren't enough days (or hours in a day for that matter).
Re: Topic 4A
April 18, 2006 08:34AM
Topic completed.
Re: Topic 4A
April 21, 2006 09:31AM
Topic completed.

I am more comfortable with:
$choice =$_POST['choice'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];


This means I create a hard link variable to the posted one. I can then use them anywhere as normal variables.

The downside though is typing $var=$_POST['var'] can be tedious for bigger forms.

Different strokes for different folks!!!

Murphy's Technology Law 7
-- The attention span of a computer
is only as long as its electrical cord.
avatar
Mac
Re: Topic 4A
April 21, 2006 03:59PM
That's why you copy the form, delete all the data around the form elements name (so you're left with

choice
firstname
lastname

Which you copy to excel, and paste in the 2nd and 3rd column.


Then you just type the $ in A1, copy, and paste the rest of the column in one stroke,

then you type the =$_POST[' in the 3rd column, copy and paste down in one stroke

then '] in the 4th column, copy and paste down...

Copy all, paste to notepad then use as code.

The same for inserting into db's etc etc.

One remaining problem is removing whitespace inbetween. That's my secret smile Google for solutions!
Re: Topic 4A
May 05, 2006 01:24PM
Took me a while but I completed it
Sorry, you do not have permission to post/reply in this forum.