PHP - Totally New To Php
Hi, I have a school project and I would like to create a simple website (very simple) to ask some survey questions and record the answers into a text file. Could someone show me sample code that will present the question
"Please discuss your best experience during the course:" presents a text box to provide the person a chance to respond and then appends the response to a file "experiences.txt" when the person selects a submit button. I have to do about 25 questions and will write the code and post an example of what I think it has to do. I just need some help getting started. I will be researching this for the next couple of weeks, anyone who can start pointing me in the right direction your help is greatly appreciated. If you feel you would be doing too much of my work for me, please point me toward a tutorial or guide document where I might be able to figure this out on my own. Thank you for the help! Mike Similar TutorialsHi folks,
Please go easy on me - total newbie. I've read all sorts of stuff on the web about how to get up and running with PHP but even the basic instructions are too complicated for me!
Here's what I want to do:
I want to use PHP to generate dynamic web pages linked to a Microsoft Access 2007 database as a test on my laptop (no need to publish to the actual Internet). I am running Windows 7 Professional SP1.
I know I need to install PHP and a web server of sorts. I tried to get IIS7 working but was foxed by the requirement to use an admin account (I don't have the admin password and didn't know how to run things as admin from my own account).
I basically need a step-by-step guide that assumes I know nothing.
Sorry if this is a big ask,
Matt
Basically, I have a series of radio buttons (wanted checkboxes) were people select either Latte, Mocha or Cappuccino. I have included a hidden field for a price and using that to bring in the prices and add them up. Code: [Select] <label for"Latte">Latte <br />€ 2.15</label> <br /> <input type="radio" name="coffee" id="Latte" value="Latte"> <input name="LattePrice" type="hidden" value="2.15"> </p> <p> <label>Mocha <br /> € 2.25</label> <br /> <input type="radio" name="coffee" id="Mocha" value="Mocha"> <input name="MochaPrice" type="hidden" value="2.25"> </p> <p> <label>Cappucino <br /> €2.35</label> <br /> <input type="radio" name="coffee" id="Cappucino" value="Cappucino"> <input name="CappPrice" type="hidden" value="2.35"> </p> The next section they choose the size they want Small, Medium or Large. Code: [Select] <p> <label for="latteSmall">Small </label><img src="images/latte.png" alt="Small Latte" width="36" height="36"> <input type="radio" name="size" id="LatteSmall" value="Small"> <input name="SizePrice" type="hidden" value="0.00"> </p> <p> <label for="LatteMedium">Medium <br /> + € 0.25 </label> <img src="images/latte.png" alt="Medium Latte" width="42" height="42"> <input type="radio" name="size" id="LatteMedium" value="Medium"> <input name="SizePrice" type="hidden" value="0.25"> </p> <p> <label for="latteLarge">Large <br /> + € 0.45 </label> <img src="images/latte.png" alt="Large Latte" width="49" height="49"> <input type="radio" name="size" id="LatteLarge" value="Large"> <input name="SizePrice" type="hidden" value="0.45"> </p> I chose radio buttons to limit the users choice to one coffee and one size to make life easier (for myself). Ideally I wanted to use checkboxes but I could not get the php working. So basically, If Latte is selected echo it and the size. Code: [Select] echo "Hi ". $name. ", " . "here is your order:" . "<br /> <br />"; echo "<strong>" . "Coffee:" . "</strong>" . "<br />" . $size . " " . $coffee . "<br /><br />"; That works fine but the pricing is coming out wrong as I was using: Code: [Select] if ($coffee == "Latte") { $TotalCoffeePrice = $LattePrice + $SizePrice; echo "€ " . $TotalCoffeePrice . "<br /> <br />"; } elseif ($coffee == "Mocha") { $TotalCoffeePrice = $MochaPrice + $SizePrice; echo "€ " . $TotalCoffeePrice . "<br /> <br />"; } elseif ($coffee == "Cappucino") { $TotalCoffeePrice = $CappPrice + $SizePrice; echo "€ " . $TotalCoffeePrice . "<br /> <br />"; } What is happening here is if you select Latte and then Small it was adding Small, Medium and Large prices to the Latte. So instead of 2.15 I was getting 2.80 or something like that. Obviously when I recognised this I tried an array but that just went arseways!! Also, at the end of the php I was hoping to total up everything that they chose with: Code: [Select] $TotalPrice = ($TotalCoffeePrice + $SizePrice + $MuffinPrice + $SamboPrice); echo "<strong>" . "Total Price:" . "</strong>" . "<br />" . "€ " .$TotalPrice . "<br /><br />"; However, this was giving a total of 9.80 even when nothing was selected! hello. i have posted something similar before and people said i should go away and learn oop. I have since done the entire Linda training on oop, watched countless videos and build a photo gallery (from the training videos) but im still stuck on this silly little thing. so please please could some one help. thanks ok, so i have 2 classes. 1 called Pages and 1 called Templates. each page has an id for the layout it wants to use. so i want to get the layoutTemps_id from the pages class and use it in a function WHERE clause to get the correct layout for that page. I cant seem to pass the layoutTemps_id into my Templates class from my Pages Class ??? i tried using a global but couldnt get it to work. ANY IDEAS ?? thanks this is the Pages class function that gets all the information for each page. Code: [Select] public static function find_by_pageName($pName){ global $database; $sql = "SELECT * FROM ".self::$table_name." WHERE pageName='".$database->escape_value($pName)."'"; $result_array = self::find_by_sql($sql); return !empty($result_array) ? array_shift($result_array) : false; } that works just fine. it gets the $pName on the page and is different each time. i.e Code: [Select] $pName = "adminHome"; $page = Pages::find_by_pageName($pName); echo $page->id."<br />"; echo $page->layoutTemps_id.'<br/>'; so that all seems to work fine. now i want to use the $page->layoutTemps_id in my Templates class. this is the class class Templates extends Pages { this is the function im trying to write. i thought that because class Templates extends Pages i could put in $page->layoutTemps_id with no problem but in stuck. Code: [Select] public static function find_layoutTemp(){ $layoutTemps_id = Pages::layoutTemps_id; $sql = "SELECT * FROM ".self::$table_name." WHERE id='".$database->escape_value($layoutTemps_id)."'"; $result_array = self::find_by_sql($sql); return !empty($result_array) ? array_shift($result_array) : false; } this is the page where im echoing the layoutTemps_id Code: [Select] <?PHP require_once("../includes/initialize.php"); $temp = Templates::find_layoutTemp(); echo "layoutTemp id " .$temp->id . " <br />"; echo "layoutTemp name " .$temp->name ." <br />"; now, i'm 100% sure there's lots wrong with my code but i'm ill be happy if someone could help. thanks rick |