Announcements | Last Post | |
---|---|---|
SoC Curricula | 09/30/2017 01:08PM | |
Demarcation or scoping of examinations and assessment | 02/13/2017 07:59AM | |
School of Computing Short Learning Programmes | 11/24/2014 08:37AM | |
Unisa contact information | 07/28/2011 01:28PM |
Lets talk php February 05, 2013 01:02PM |
Registered: 17 years ago Posts: 66 Rating: 0 |
What is session?Language: PHP<?php session_start(); // start up your PHP session! ?>
Re: Lets talk php February 11, 2013 12:06PM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Php forms February 11, 2013 12:24PM |
Registered: 11 years ago Posts: 3 Rating: 0 |
Re: Re: Lets talk php February 11, 2013 12:57PM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: Php forms February 11, 2013 01:02PM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: Php forms February 11, 2013 01:11PM |
Registered: 17 years ago Posts: 66 Rating: 0 |
Language: PHP<?php function myGreeting($firstName){ echo "Hello there ". $firstName . "!<br />"; } ?>
This HTML code specifies that the form data will be submitted to the "process.php" web page using the POST method. The way that PHP does this is to store all the "posted" values into an associative array called "$_POST". Be sure to take notice the names of the form data names, as they represent the keys in the "$_POST" associative array.Language: PHP<form action="process.php" method="get"> <select name="item"> ... <input name="quantity" type="text" />
Re: Lets talk php February 12, 2013 09:59PM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Re: Lets talk php February 13, 2013 11:21PM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Language: PHPif (isset($_POST[';Submit';])) { $username = $_POST[';username';]; if ($username = = "letmein") { print ("Welcome back, friend!"); } else { print ("You';re not a member of this site"); } }
Re: Lets talk php February 14, 2013 07:42AM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Language: PHPif (isset($_POST[';Submit';])) { $username = $_POST[';username';]; if ($username = = "letmein") { print ("Welcome back, friend!"); } else { print ("You';re not a member of this site"); } }
Re: Re: Lets talk php February 14, 2013 10:14AM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Re: Php forms February 17, 2013 07:32AM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Re: Php forms February 18, 2013 09:52AM |
Registered: 11 years ago Posts: 23 Rating: 0 |
Language: PHPif ($username = = "letmein") { print ("Welcome back, friend!"); }
Language: PHPif ($username == "letmein") { print ("Welcome back, friend!"); }
Language: PHP$var1 = "10"; $var2 = 10; if ( $var1 == $var2 ) { // do some thing echo "{$var1} is the same as {$var2} using == "; } if ( $var1 === $var2 ) { // do some thing echo "{$var1} is the same as {$var2} using === "; } // The answer will be the first if statement answer.... // So the === is very strict when it comes to data type so $var1 was supposed to be 10 not "10" then both the if statements could have worked // so if you really want to check for equality and the type of the data if its a string, integer or other data types you must use ===
Re: Lets talk php February 18, 2013 01:11PM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Re: Lets talk php February 26, 2013 09:49AM |
Registered: 17 years ago Posts: 66 Rating: 0 |
so i tried to put @ symbol infront of the $Username which will result on no error outputLanguage: PHP// connetion <?php include("../config.php"); ?> <?php $Username = $_POST[';username';]; $Mypassword = $_POST[';password';]; $comment= $_POST[';comment';]; // send the data to the database ?>
is this this a right solution to undefined index if not what is the solution? After this i got new error looking like thisLanguage: PHP@ $Username = $_POST[';username';];
Now i'm stuckedLanguage: SQLmysql_num_rows() expects parameter 1 TO be resource, BOOLEAN given IN
Re: Re: Lets talk php February 26, 2013 10:32AM |
Registered: 11 years ago Posts: 23 Rating: 0 |
Re: Lets talk php February 26, 2013 10:56AM |
Registered: 11 years ago Posts: 23 Rating: 0 |
Re: Lets talk php February 26, 2013 12:02PM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Language: PHPif(isset($_POST[';username';])) { $username=$_POST[';username';]; // do what you want to do
Re: Lets talk php February 26, 2013 07:42PM |
Registered: 17 years ago Posts: 66 Rating: 0 |
outputLanguage: PHP<?php // turn on buffering, no output ob_start(); session_start(); include("../scripts-pvt/config.php"); $tbl_name="members"; //table name //Define 4myusername and $password if(isset($_POST[';myusername';])) { $username=$_POST[';myusername';]; //@$myusername=$_POST['; myusername';]; //$mypassword=$_POST['; mypassword';]; if(isset($_POST[';mypassword';])) $mypassword=$_POST[';mypassword';]; $mypage=$_SESSION['; page';]; } // to protect MySQl injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); //http://php.net/manual/en/function.mysql-real-escape-string.php $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql= "SELECT * FROM $tbl_name WHERE Members_Username=';$myusername'; and Member_Password=';$mypassword';"; $result = mysql_query($query) or die(mysql_error()); //Mysql _num_row is Counting table $count = mysql_num_rows($result); //if the result matched $myusername and $password, table row must be 1 row if($count==1){ //Register $myusername, $mypassword and redirect to file "login_success.php" echo $page; $_SESSION['; myusername';] = $myusername; $_SESSION['; mypassword';] = $mypassword; header($mypage); } else{ echo"wrong username or password"; } //turn off buffering ob_end_flush(); ?>
Re: Lets talk php February 27, 2013 08:24AM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Language: PHP$sql= "SELECT * FROM $tbl_name WHERE Members_Username=';$myusername'; and Member_Password=';$mypassword';"; $result = mysql_query($sql) or die(mysql_error());
Language: PHP$username = mysql_real_escape_string(strip_slashes($_POST[';username';]));
Language: PHP$username=$_POST[';myusername';]; //but furtherdown you use $myusername = stripslashes($myusername);
Language: PHPif(isset($_POST[';myusername';])) { $myusername=$_POST[';myusername';]; } if(isset($_POST[';mypassword';])) { $mypassword=$_POST[';mypassword';]; }
Re: Re: Lets talk php February 27, 2013 08:46AM |
Registered: 11 years ago Posts: 23 Rating: 0 |
Language: HTML<form action="checklogin.php" method="post"> <input type="text" name="myusername" /> <input type="password" name="mypassword" /> </form>
Language: PHPif ( isset( $_POST[';myusername';] ) ) $myusername = $_POST[';myusername';]; if ( isset( $_POST[';mypassword';] ) ) $myusername = $_POST[';mypassword';];
Language: PHP//Define 4myusername and $password if(isset($_POST[';myusername';])) { $username=$_POST[';myusername';]; //@$myusername=$_POST['; myusername';]; //$mypassword=$_POST['; mypassword';]; if(isset($_POST[';mypassword';])) $mypassword=$_POST[';mypassword';]; $mypage=$_SESSION['; page';]; }
Language: PHP//Define 4myusername and $password if(isset($_POST[';myusername';])) { $username=$_POST[';myusername';]; // So you declared the ';myusername'; post value as $username not $myusername..... that';s why you get an Undefined variable myusername } //@$myusername=$_POST['; myusername';]; //$mypassword=$_POST['; mypassword';]; if(isset($_POST[';mypassword';])) { $mypassword=$_POST[';mypassword';]; // You getting an Undefined variable mypassword because of your incorrect if statement braces $mypage=$_SESSION[';page';]; // Notice there';s no space '; page'; but ';page'; }
Language: PHP// User $query or $sql and stick to one $query = "SELECT * FROM {$tbl_name} WHERE Members_Username={$myusername} and Member_Password={$mypassword}"; // Assuming that in the members table you have the cols ';Member_Username'; and ';Member_Password'; with uppercase $result = mysql_query($query) or die(mysql_error()); // This is fine (but in your case you must use $sql not $query) Undefined $query because you declared you query as $sql $count = mysql_num_rows($result); // Then this should now work
Language: PHPif ( $count == 1 ) { // If you are using the header() function you must not echo any code above it won';t work // And your session variable please remove the space before the post input name e.g. $_SESSION['; myusername';] = $myusername; $_SESSION['; mypassword';] = $mypassword; // MUST BE: $_SESSION[';myusername';] = $myusername; $_SESSION[';mypassword';] = $mypassword; }
Language: PHP// $_SESSION[';page';];
Re: Re: Re: Lets talk php February 27, 2013 08:52AM |
Registered: 11 years ago Posts: 23 Rating: 0 |
Language: PHP// User $query or $sql and stick to one $query = "SELECT * FROM {$tbl_name} WHERE Members_Username={$myusername} and Member_Password={$mypassword}";
Language: PHP// User $query or $sql and stick to one $query = "SELECT * FROM {$tbl_name} WHERE Members_Username={$myusername} AND Member_Password={$mypassword}";
Re: Lets talk php February 27, 2013 09:33AM |
Registered: 17 years ago Posts: 66 Rating: 0 |
Re: Re: Lets talk php February 27, 2013 09:57AM |
Registered: 11 years ago Posts: 23 Rating: 0 |
Re: Lets talk php March 01, 2013 02:47PM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Re: Re: Lets talk php March 01, 2013 02:52PM |
Registered: 11 years ago Posts: 23 Rating: 0 |
Re: Lets talk php March 01, 2013 03:48PM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: Lets talk php March 04, 2013 07:05AM |
Registered: 11 years ago Posts: 34 Rating: 0 |
Language: PHP<html> <head> <title>login form</title> <?PHP if (isset($_POST[';Submit';])) { $Firstname = $_POST[';Firstname';]; $Surname = $_POST[';Surname';]; print ("......ICT College REGISTRATION FORM......."); } echo "<div>\n"; echo " <br /> \n"; $male_status = ';unchecked';; $female_status = ';unchecked';; if (isset($_POST[';Submit';])) { $selected_radio = $_POST[';gender';]; if ($selected_radio == ';Male';) { $male_status = ';checked';; print ("YOUR NAME : Mr "."$Firstname"." $Surname"." "); echo "<div>\n"; echo " <br /> \n"; print ("GENDER : "); print ("$selected_radio"); echo "<div>\n"; echo " <br /> \n"; } else if ($selected_radio == ';Female';) { $female_status = ';checked';; print ("YOUR NAME : Ms "."$Firstname"." $Surname"." "); echo "<div>\n"; echo " <br /> \n"; print ("GENDER : "); print ("$selected_radio"); echo "<div>\n"; echo " <br /> \n"; } else { $Firstname =""; $Surname =""; } echo "<div>\n"; echo " <br /> \n"; print("LANGUAGES CHOSEN ARE: "); echo "<div>\n"; echo " <br /> \n"; $ch1 = ';unchecked';; $ch2 = ';unchecked';; $ch3 = ';unchecked';; $ch4 = ';unchecked';; $ch5 = ';unchecked';; if (isset($_POST[';Submit';])) { if (isset($_POST[';ch1';])) { $ch1 = $_POST[';ch1';]; print $selected_Checkbox; if ($ch1 == ';Afrikaans';) { print("$ch1"); $ch1 = ';checked';; echo "<div>\n"; echo " <br /> \n"; } } if (isset($_POST[';ch2';])) { $ch2 = $_POST[';ch2';]; if ($ch2 == ';English';) { print("$ch2"); echo "<div>\n"; echo " <br /> \n"; $ch2 = ';checked';; } } if (isset($_POST[';ch3';])) { $ch3 = $_POST[';ch3';]; if ($ch3 == ';Suthu';) { print("$ch3"); echo "<div>\n"; echo " <br /> \n"; $ch3 = ';checked';; } } if (isset($_POST[';ch4';])) { $ch4 = $_POST[';ch4';]; if ($ch4 == ';Setswana';) { print("$ch4"); echo "<div>\n"; echo " <br /> \n"; $ch4 = ';checked';; } } if (isset($_POST[';ch5';])) { $ch5 = $_POST[';ch5';]; if ($ch5 == ';Zulu';) { print("$ch5"); echo "<div>\n"; echo " <br /> \n"; $ch5 = ';checked';; } } $itcourses = array(); $itcourses["msitp"] = "MicroSoft ITP Certification - R7000 "; $itcourses["cisa"] = "CISA ISACA Certification - R5000"; $itcourses["linux"] = "Linux+ Comptia Certification - R2000 "; $itcourses["ccna"] = "Explorer CCNA CISCO Certification - RR4500"; $itcourses["java"] = "Java Sun Certification - 6000 "; print("OTHER IT COURSES @ ITC COLLEGE"); echo "<div>\n"; echo " <br /> \n"; print $itcourses["linux"]; echo "<div>\n"; echo " <br /> \n"; print $itcourses["cisa"]; echo "<div>\n"; echo " <br /> \n"; print $itcourses["java"]; echo "<div>\n"; echo " <br /> \n"; print $itcourses["ccna"]; echo "<div>\n"; echo " <br /> \n"; print $itcourses["msitp"]; echo "<div>\n"; echo " <br /> \n"; print("......Ts and Cs Apply......Goodbye......"); echo "<div>\n"; echo " <br /> \n"; } } ?> </head> <body> <Form name ="form1" Method ="POST" Action ="am_regform.php"> <FORM name ="form1" Method ="post" action ="am_regform.php"> <INPUT TYPE = "TEXT" VALUE ="Enter Firstname here!" Name ="Firstname"> <INPUT TYPE = "TEXT" VALUE ="Enter Surname here!" Name ="Surname"> <br /> <Input type = ';Radio'; Name =';gender'; value= ';Male'; <?PHP print $male_status; ?> >Male <Input type = ';Radio'; Name =';gender'; value= ';Female'; <?PHP print $female_status; ?> >Female <P> <Input type = ';Checkbox'; Name =';ch1'; value ="Afrikaans" <?PHP print "$ch1"; ?> >Afrikaans <P> <Input type = ';Checkbox'; Name =';ch2'; value="English" <?PHP print $ch2; ?> >English <P> <Input type = ';Checkbox'; Name =';ch3'; value="Suthu" <?PHP print $ch3; ?> >Suthu <P> <Input type = ';Checkbox'; Name =';ch4'; value="Setswana" <?PHP print $ch4; ?> >Setswana <P> <Input type = ';Checkbox'; Name =';ch5'; value="Zulu" <?PHP print $ch5; ?> >Zulu <P> <INPUT TYPE = "Submit" Name = "Submit" VALUE = "Click here to submit details"> </FORM> </body> </html>
Re: Lets talk php March 04, 2013 08:12AM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: Re: Lets talk php March 04, 2013 08:23AM |
Registered: 11 years ago Posts: 38 Rating: 0 |
Re: Re: Re: Lets talk php March 04, 2013 01:55PM |
Registered: 11 years ago Posts: 20 Rating: 0 |
Re: Lets talk php March 04, 2013 07:18PM |
Registered: 11 years ago Posts: 4 Rating: 0 |
Re: Lets talk php March 06, 2013 01:16PM |
Registered: 11 years ago Posts: 34 Rating: 0 |
Language: PHP$itcourses = array(); $itcourses["msitp"] = "MicroSoft ITP Certification - R7000 "; $itcourses["cisa"] = "CISA ISACA Certification - R5000"; $itcourses["linux"] = "Linux+ Comptia Certification - R2000 "; $itcourses["ccna"] = "Explorer CCNA CISCO Certification - RR4500"; $itcourses["java"] = "Java Sun Certification - 6000 ";
way. Will this be the best way in inputting values into arrays as well?.Will arrays be the best for this situation? in a nutshell m jus askin how can the user be prompted to enter the size of the array and enter items into the array, hope u understand my question.Language: PHP<INPUT TYPE = "TEXT" VALUE ="Enter Course here!" Name ="Course">
Re: Re: Lets talk php March 06, 2013 01:58PM |
Registered: 11 years ago Posts: 23 Rating: 0 |
Language: HTML<select name="courses"> <option value="msitp">MicroSoft ITP Certification - R7000</option> <option value="cisa">CISA ISACA Certification - R5000</option> <!-- and so on --> </select>
Re: Lets talk php March 06, 2013 02:42PM |
Admin Registered: 18 years ago Posts: 10,001 Rating: 353 |
Re: Lets talk php March 06, 2013 02:59PM |
Registered: 11 years ago Posts: 34 Rating: 0 |
Re: Re: Lets talk php March 06, 2013 03:09PM |
Registered: 11 years ago Posts: 23 Rating: 0 |
Re: Lets talk php March 07, 2013 07:52AM |
Registered: 11 years ago Posts: 163 Rating: 0 |
Re: Re: Lets talk php March 07, 2013 08:20AM |
Registered: 11 years ago Posts: 23 Rating: 0 |