Monday 25 February 2013

the php file upload task




In the second part of the class we looked at the php file upload code found on w3schools. The code i uploaded here is fully functioning and works. I had it set up to save in an uploads folder in my htdoc file in xampp on pc side.

this piece of code here:

error_reporting(E_ALL ^ E_STRICT);

(gets rid of any errors that may occur when running the code and in w3schools there is a piece of code within the suggested code for size but because its giving so may errors for students i removed it to make the code work.)

next week we will be doing cookies.

date and timestamp in php

we went through this topic in todays php class

<?php
echo date("Y/m/d") . "<br>";
echo date("Y.m.d") . "<br>";
echo date("Y-m-d");
?>


and

<?php
$tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y"));
echo "Tomorrow is ".date("Y/m/d", $tomorrow);
?>


the output is:

Tomorrow is 2009/05/12

4 base pizza session in php task





these are the screen shots for the php code that was used. i havent finished testing it so its not complete. We did this in todays class (25.02.13). The will be html on all pages so we must use dreamweaver. all ways use lower case for the html values and always set a value to call in the html.

she gave us a little bit of code for making the check boxes work:

page 3:

<form action="" method="post">
<input type="checkbox" name="check_list[]" alt="Checkbox" value="one">
<input type="checkbox" name="check_list[]" alt="Checkbox" value="two">
<input type="checkbox" name="check_list[]" alt="Checkbox" value="three">
<button type="submit">submit</button>
</form>
page 4:
<?php

echo "Check box test<pre>" ;
//print_r($check_list);
echo "</pre>";
if(!empty($_POST['check_list'])) {
foreach($_POST['check_list'] as $check) {
echo "check=$check<br>";
}
}
?>

this is all available on moodle titles display.php

she then gave a new task to do in our spare time:

titled student:

firstpage: knumber and password with submit button
second page: class with 4 radio button options
third page: fund money with 4 check boxes
forth page: details and confirmation

















Thursday 21 February 2013

links for random number generator in php

http://stackoverflow.com/questions/5612656/generating-unique-random-numbers-within-a-range-php

http://stackoverflow.com/questions/4990752/how-i-can-generate-6-random-numbers-php

Tuesday 19 February 2013

project 1 brief

lotto ticket outline of the brief: 10%


deliverables


  1. display the tickets
  2. find the winner
  3. display the winning ticket number
  4. find the winners who matched 3 or more numbers
  5. all numbers on each ticket must be unique
conditions

  1. there must be 100 tickets
  2. each ticket must have 6 numbers on it between 1 - 42
  3. each ticket number must be unique
  4. the winning ticket selection must be random
thoughts

I have four functions so far:

function displayticket();
function findwinner();
function showwinner(); - this may be in the previous function
function diysplaytop3();


The deadline is the 28.02.13

form handling in php





































Notes on mondays class 

the aim of correct form handling in php is that when the submit button is clicked that all the details athat are entered are processed correctly.

Example

Name= value & name=value
?firstname=liz&lastname=bouke & age =$& address + & email = liz.lit.ie

there are two functions in php required: $_GET and $_POST

Part 1 - html

<p><label for="firstname"></abel>
firstname<input type="text"  name="firstname" id="firstname"/>

-this code is used for each text field you will create.

Part 2 - php

see the second image

Part 3 - isset function

if i have the values get the values but if i do not have the 
values wait without an error display for values to be put in.