PHP - Learning Php, Java Dev With A Headache.
i Have this Form
<form action="action_page.php" method="POST"> <div class="form-group"> <label for="email">Email address:</label> <input type="email" class="form-control" id="email"> </div> <div class="form-group"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd"> </div> <div class="checkbox"> <label><input type="checkbox"> Remember me</label> </div> <button type="submit" class="btn btn-default">Submit</button> </form>
And im trying to pass the information into a USER class and print out the result in a action_page.php.
<?php class User { private $password; private $emailAddress; function __construct() { $this->emailAddress = isset($_POST['email']) ? $_POST['email'] : null; $this->password = isset($_POST['pwd']) ? $_POST['pwd'] : null; } function start() { if (empty($this->password) || empty($this->emailAddress)) { throw new Exception("Empty Post not allowed"); } else { echo " Registration Done"; } } }
$register = new User(); if(!empty($_POST)) { $register->start(); }
Then in my action page i try to refernence the Object with
?php include "User.php"; $user = new User(); try { $user->start(); } catch (Exception $e) { echo "Cannot Find account"; }
but it never can do it ? Anyone any ideas ??
Similar TutorialsHi All, I am trying to convert HTMLentities style encoding, to UTF decimal encoding. I.e. int the text: U+001D 1d <control><br /> U+007D } 7d RIGHT CURLY BRACKET<br /> U+00A2 ¢ c2 a2 CENT SIGN<br /> I want the ¢ to be its UTF decimal equivalent. that make sense?? Basically, i'm parsing text for an epub and it wont accept special characters in the html entities form - only the decimal form. Rubbish eh? The entire test text i am using is this (there is some HTML in there you see that i DO NOT want converting - basically only things between the &.. THANKS! <html xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Testing images</title> <link href="stylesheet.css" charset="UTF-8" type="text/css" rel="stylesheet" /> </head> <body><h2>Character Testing</h2><p align='justify'>U+0000 00 <control><br /> U+0001 01 <control><br /> U+0002 02 <control><br /> U+0003 03 <control><br /> U+0004 04 <control><br /> U+0005 05 <control><br /> U+0006 06 <control><br /> U+0007 07 <control><br /> U+0008 08 <control><br /> U+0009 09 <control><br /> U+000A 0a <control><br /> U+000B 0b <control><br /> U+000C 0c <control><br /> U+000D 0d <control><br /> U+000E 0e <control><br /> U+000F 0f <control><br /> U+0010 10 <control><br /> U+0011 11 <control><br /> U+0012 12 <control><br /> U+0013 13 <control><br /> U+0014 14 <control><br /> U+0015 15 <control><br /> U+0016 16 <control><br /> U+0017 17 <control><br /> U+0018 18 <control><br /> U+0019 19 <control><br /> U+001A 1a <control><br /> U+001B 1b <control><br /> U+001C 1c <control><br /> U+001D 1d <control><br /> U+001E 1e <control><br /> U+001F 1f <control><br /> U+0020 20 SPACE<br /> U+0021 ! 21 EXCLAMATION MARK<br /> U+0022 " 22 QUOTATION MARK<br /> U+0023 # 23 NUMBER SIGN<br /> U+0024 $ 24 DOLLAR SIGN<br /> U+0025 % 25 PERCENT SIGN<br /> U+0026 & 26 AMPERSAND<br /> U+0027 ' 27 APOSTROPHE<br /> U+0028 ( 28 LEFT PARENTHESIS<br /> U+0029 ) 29 RIGHT PARENTHESIS<br /> U+002A * 2a ASTERISK<br /> U+002B + 2b PLUS SIGN<br /> U+002C , 2c COMMA<br /> U+002D - 2d HYPHEN-MINUS<br /> U+002E . 2e FULL STOP<br /> U+002F / 2f SOLIDUS<br /> U+0030 0 30 DIGIT ZERO<br /> U+0031 1 31 DIGIT ONE<br /> U+0032 2 32 DIGIT TWO<br /> U+0033 3 33 DIGIT THREE<br /> U+0034 4 34 DIGIT FOUR<br /> U+0035 5 35 DIGIT FIVE<br /> U+0036 6 36 DIGIT SIX<br /> U+0037 7 37 DIGIT SEVEN<br /> U+0038 8 38 DIGIT EIGHT<br /> U+0039 9 39 DIGIT NINE<br /> U+003A : 3a COLON<br /> U+003B ; 3b SEMICOLON<br /> U+003C < 3c LESS-THAN SIGN<br /> U+003D = 3d EQUALS SIGN<br /> U+003E > 3e GREATER-THAN SIGN<br /> U+003F ? 3f QUESTION MARK<br /> U+0040 @ 40 COMMERCIAL AT<br /> U+0041 A 41 LATIN CAPITAL LETTER A<br /> U+0042 B 42 LATIN CAPITAL LETTER B<br /> U+0043 C 43 LATIN CAPITAL LETTER C<br /> U+0044 D 44 LATIN CAPITAL LETTER D<br /> U+0045 E 45 LATIN CAPITAL LETTER E<br /> U+0046 F 46 LATIN CAPITAL LETTER F<br /> U+0047 G 47 LATIN CAPITAL LETTER G<br /> U+0048 H 48 LATIN CAPITAL LETTER H<br /> U+0049 I 49 LATIN CAPITAL LETTER I<br /> U+004A J 4a LATIN CAPITAL LETTER J<br /> U+004B K 4b LATIN CAPITAL LETTER K<br /> U+004C L 4c LATIN CAPITAL LETTER L<br /> U+004D M 4d LATIN CAPITAL LETTER M<br /> U+004E N 4e LATIN CAPITAL LETTER N<br /> U+004F O 4f LATIN CAPITAL LETTER O<br /> U+0050 P 50 LATIN CAPITAL LETTER P<br /> U+0051 Q 51 LATIN CAPITAL LETTER Q<br /> U+0052 R 52 LATIN CAPITAL LETTER R<br /> U+0053 S 53 LATIN CAPITAL LETTER S<br /> U+0054 T 54 LATIN CAPITAL LETTER T<br /> U+0055 U 55 LATIN CAPITAL LETTER U<br /> U+0056 V 56 LATIN CAPITAL LETTER V<br /> U+0057 W 57 LATIN CAPITAL LETTER W<br /> U+0058 X 58 LATIN CAPITAL LETTER X<br /> U+0059 Y 59 LATIN CAPITAL LETTER Y<br /> U+005A Z 5a LATIN CAPITAL LETTER Z<br /> U+005B [ 5b LEFT SQUARE BRACKET<br /> U+005C \ 5c REVERSE SOLIDUS<br /> U+005D ] 5d RIGHT SQUARE BRACKET<br /> U+005E ^ 5e CIRCUMFLEX ACCENT<br /> U+005F _ 5f LOW LINE<br /> U+0060 ` 60 GRAVE ACCENT<br /> U+0061 a 61 LATIN SMALL LETTER A<br /> U+0062 b 62 LATIN SMALL LETTER B<br /> U+0063 c 63 LATIN SMALL LETTER C<br /> U+0064 d 64 LATIN SMALL LETTER D<br /> U+0065 e 65 LATIN SMALL LETTER E<br /> U+0066 f 66 LATIN SMALL LETTER F<br /> U+0067 g 67 LATIN SMALL LETTER G<br /> U+0068 h 68 LATIN SMALL LETTER H<br /> U+0069 i 69 LATIN SMALL LETTER I<br /> U+006A j 6a LATIN SMALL LETTER J<br /> U+006B k 6b LATIN SMALL LETTER K<br /> U+006C l 6c LATIN SMALL LETTER L<br /> U+006D m 6d LATIN SMALL LETTER M<br /> U+006E n 6e LATIN SMALL LETTER N<br /> U+006F o 6f LATIN SMALL LETTER O<br /> U+0070 p 70 LATIN SMALL LETTER P<br /> U+0071 q 71 LATIN SMALL LETTER Q<br /> U+0072 r 72 LATIN SMALL LETTER R<br /> U+0073 s 73 LATIN SMALL LETTER S<br /> U+0074 t 74 LATIN SMALL LETTER T<br /> U+0075 u 75 LATIN SMALL LETTER U<br /> U+0076 v 76 LATIN SMALL LETTER V<br /> U+0077 w 77 LATIN SMALL LETTER W<br /> U+0078 x 78 LATIN SMALL LETTER X<br /> U+0079 y 79 LATIN SMALL LETTER Y<br /> U+007A z 7a LATIN SMALL LETTER Z<br /> U+007B { 7b LEFT CURLY BRACKET<br /> U+007C | 7c VERTICAL LINE<br /> U+007D } 7d RIGHT CURLY BRACKET<br /> U+007E ~ 7e TILDE<br /> U+007F 7f <control><br /> U+0080 c2 80 <control><br /> U+0081 c2 81 <control><br /> U+0082 c2 82 <control><br /> U+0083 c2 83 <control><br /> U+0084 c2 84 <control><br /> U+0085 c2 85 <control><br /> U+0086 c2 86 <control><br /> U+0087 c2 87 <control><br /> U+0088 c2 88 <control><br /> U+0089 c2 89 <control><br /> U+008A c2 8a <control><br /> U+008B c2 8b <control><br /> U+008C c2 8c <control><br /> U+008D c2 8d <control><br /> U+008E c2 8e <control><br /> U+008F c2 8f <control><br /> U+0090 c2 90 <control><br /> U+0091 c2 91 <control><br /> U+0092 c2 92 <control><br /> U+0093 c2 93 <control><br /> U+0094 c2 94 <control><br /> U+0095 c2 95 <control><br /> U+0096 c2 96 <control><br /> U+0097 c2 97 <control><br /> U+0098 c2 98 <control><br /> U+0099 c2 99 <control><br /> U+009A c2 9a <control><br /> U+009B c2 9b <control><br /> U+009C c2 9c <control><br /> U+009D c2 9d <control><br /> U+009E c2 9e <control><br /> U+009F c2 9f <control><br /> U+00A0 c2 a0 NO-BREAK SPACE<br /> U+00A1 ¡ c2 a1 INVERTED EXCLAMATION MARK<br /> U+00A2 ¢ c2 a2 CENT SIGN<br /> U+00A3 £ c2 a3 POUND SIGN<br /> U+00A4 ¤ c2 a4 CURRENCY SIGN<br /> U+00A5 ¥ c2 a5 YEN SIGN<br /> U+00A6 ¦ c2 a6 BROKEN BAR<br /> U+00A7 § c2 a7 SECTION SIGN<br /> U+00A8 ¨ c2 a8 DIAERESIS<br /> U+00A9 © c2 a9 COPYRIGHT SIGN<br /> U+00AA ª c2 aa FEMININE ORDINAL INDICATOR<br /> U+00AB « c2 ab LEFT-POINTING DOUBLE ANGLE QUOTATION MARK<br /> U+00AC ¬ c2 ac NOT SIGN<br /> U+00AD c2 ad SOFT HYPHEN<br /> U+00AE ® c2 ae REGISTERED SIGN<br /> U+00AF ¯ c2 af MACRON<br /> U+00B0 ° c2 b0 DEGREE SIGN<br /> U+00B1 ± c2 b1 PLUS-MINUS SIGN<br /> U+00B2 ² c2 b2 SUPERSCRIPT TWO<br /> U+00B3 ³ c2 b3 SUPERSCRIPT THREE<br /> U+00B4 ´ c2 b4 ACUTE ACCENT<br /> U+00B5 µ c2 b5 MICRO SIGN<br /> U+00B6 ¶ c2 b6 PILCROW SIGN<br /> U+00B7 · c2 b7 MIDDLE DOT<br /> U+00B8 ¸ c2 b8 CEDILLA<br /> U+00B9 ¹ c2 b9 SUPERSCRIPT ONE<br /> U+00BA º c2 ba MASCULINE ORDINAL INDICATOR<br /> U+00BB » c2 bb RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK<br /> U+00BC ¼ c2 bc VULGAR FRACTION ONE QUARTER<br /> U+00BD ½ c2 bd VULGAR FRACTION ONE HALF<br /> U+00BE ¾ c2 be VULGAR FRACTION THREE QUARTERS<br /> U+00BF ¿ c2 bf INVERTED QUESTION MARK<br /> U+00C0 À c3 80 LATIN CAPITAL LETTER A WITH GRAVE<br /> U+00C1 Á c3 81 LATIN CAPITAL LETTER A WITH ACUTE<br /> U+00C2 Â c3 82 LATIN CAPITAL LETTER A WITH CIRCUMFLEX<br /> U+00C3 Ã c3 83 LATIN CAPITAL LETTER A WITH TILDE<br /> U+00C4 Ä c3 84 LATIN CAPITAL LETTER A WITH DIAERESIS<br /> U+00C5 Å c3 85 LATIN CAPITAL LETTER A WITH RING ABOVE<br /> U+00C6 Æ c3 86 LATIN CAPITAL LETTER AE<br /> U+00C7 Ç c3 87 LATIN CAPITAL LETTER C WITH CEDILLA<br /> U+00C8 È c3 88 LATIN CAPITAL LETTER E WITH GRAVE<br /> U+00C9 É c3 89 LATIN CAPITAL LETTER E WITH ACUTE<br /> U+00CA Ê c3 8a LATIN CAPITAL LETTER E WITH CIRCUMFLEX<br /> U+00CB Ë c3 8b LATIN CAPITAL LETTER E WITH DIAERESIS<br /> U+00CC Ì c3 8c LATIN CAPITAL LETTER I WITH GRAVE<br /> U+00CD Í c3 8d LATIN CAPITAL LETTER I WITH ACUTE<br /> U+00CE Î c3 8e LATIN CAPITAL LETTER I WITH CIRCUMFLEX<br /> U+00CF Ï c3 8f LATIN CAPITAL LETTER I WITH DIAERESIS<br /> U+00D0 Ð c3 90 LATIN CAPITAL LETTER ETH<br /> U+00D1 Ñ c3 91 LATIN CAPITAL LETTER N WITH TILDE<br /> U+00D2 Ò c3 92 LATIN CAPITAL LETTER O WITH GRAVE<br /> U+00D3 Ó c3 93 LATIN CAPITAL LETTER O WITH ACUTE<br /> U+00D4 Ô c3 94 LATIN CAPITAL LETTER O WITH CIRCUMFLEX<br /> U+00D5 Õ c3 95 LATIN CAPITAL LETTER O WITH TILDE<br /> U+00D6 Ö c3 96 LATIN CAPITAL LETTER O WITH DIAERESIS<br /> U+00D7 × c3 97 MULTIPLICATION SIGN<br /> U+00D8 Ø c3 98 LATIN CAPITAL LETTER O WITH STROKE<br /> U+00D9 Ù c3 99 LATIN CAPITAL LETTER U WITH GRAVE<br /> U+00DA Ú c3 9a LATIN CAPITAL LETTER U WITH ACUTE<br /> U+00DB Û c3 9b LATIN CAPITAL LETTER U WITH CIRCUMFLEX<br /> U+00DC Ü c3 9c LATIN CAPITAL LETTER U WITH DIAERESIS<br /> U+00DD Ý c3 9d LATIN CAPITAL LETTER Y WITH ACUTE<br /> U+00DE Þ c3 9e LATIN CAPITAL LETTER THORN<br /> U+00DF ß c3 9f LATIN SMALL LETTER SHARP S<br /> U+00E0 à c3 a0 LATIN SMALL LETTER A WITH GRAVE<br /> U+00E1 á c3 a1 LATIN SMALL LETTER A WITH ACUTE<br /> U+00E2 â c3 a2 LATIN SMALL LETTER A WITH CIRCUMFLEX<br /> U+00E3 ã c3 a3 LATIN SMALL LETTER A WITH TILDE<br /> U+00E4 ä c3 a4 LATIN SMALL LETTER A WITH DIAERESIS<br /> U+00E5 å c3 a5 LATIN SMALL LETTER A WITH RING ABOVE<br /> U+00E6 æ c3 a6 LATIN SMALL LETTER AE<br /> U+00E7 ç c3 a7 LATIN SMALL LETTER C WITH CEDILLA<br /> U+00E8 è c3 a8 LATIN SMALL LETTER E WITH GRAVE<br /> U+00E9 é c3 a9 LATIN SMALL LETTER E WITH ACUTE<br /> U+00EA ê c3 aa LATIN SMALL LETTER E WITH CIRCUMFLEX<br /> U+00EB ë c3 ab LATIN SMALL LETTER E WITH DIAERESIS<br /> U+00EC ì c3 ac LATIN SMALL LETTER I WITH GRAVE<br /> U+00ED í c3 ad LATIN SMALL LETTER I WITH ACUTE<br /> U+00EE î c3 ae LATIN SMALL LETTER I WITH CIRCUMFLEX<br /> U+00EF ï c3 af LATIN SMALL LETTER I WITH DIAERESIS<br /> U+00F0 ð c3 b0 LATIN SMALL LETTER ETH<br /> U+00F1 ñ c3 b1 LATIN SMALL LETTER N WITH TILDE<br /> U+00F2 ò c3 b2 LATIN SMALL LETTER O WITH GRAVE<br /> U+00F3 ó c3 b3 LATIN SMALL LETTER O WITH ACUTE<br /> U+00F4 ô c3 b4 LATIN SMALL LETTER O WITH CIRCUMFLEX<br /> U+00F5 õ c3 b5 LATIN SMALL LETTER O WITH TILDE<br /> U+00F6 ö c3 b6 LATIN SMALL LETTER O WITH DIAERESIS<br /> U+00F7 ÷ c3 b7 DIVISION SIGN<br /> U+00F8 ø c3 b8 LATIN SMALL LETTER O WITH STROKE<br /> U+00F9 ù c3 b9 LATIN SMALL LETTER U WITH GRAVE<br /> U+00FA ú c3 ba LATIN SMALL LETTER U WITH ACUTE<br /> U+00FB û c3 bb LATIN SMALL LETTER U WITH CIRCUMFLEX<br /> U+00FC ü c3 bc LATIN SMALL LETTER U WITH DIAERESIS<br /> U+00FD ý c3 bd LATIN SMALL LETTER Y WITH ACUTE<br /> U+00FE þ c3 be LATIN SMALL LETTER THORN<br /> U+00FF ÿ c3 bf LATIN SMALL LETTER Y WITH DIAERESIS</p> </body> </html> Hi there. I'm trying to create my own search function for users to search for events between certain dates. One option I have is 'within next 7 days'. So, within the SQL function I am searching "... WHERE eventdate between $from and $to.." The $from variable I figured would be $from = date('d-m-Y',time()); (ie- todays date)... but how would I find the date in 7 days?. I've seen strtotime mentioned about the web but can't figure how this applies. Any help would be marvelous! Cheers, Paddyfields. Hi all, I am having bit of a headache in trying to achieve what I want! Basically I have a date coming into the script as this format: Tue May 24 18:51:38 +0000 2011 These are the steps I wish to do an not quite sure how! 1. Make date read: May 24 2011 2. Add 6 Months to date and store as new variable For part 2 I am guessing I can do something like: Code: [Select] <?php $futuredate = strtotime('+6 months', $date) ?>; But part one is stumping me! Thanks Hi All,
I seem to be getting in a right mess with this, so hope someone can help.
I'm simply trying to set a cookie called 'defaultLanguage'.
It will initially be set to English and when someone completes a form, the form value is then passed and used in the cookie.
here's my code:
$cookie_name = 'defaultLanguage'; $cookie_value = $_GET["language"]; if ($cookie_value == ''){ $cookie_value = 'English'; }else{ $cookie_value = $_GET["language"]; } setcookie($cookie_name, $cookie_value, time() + (86400 * 30), '/'); // 86400 = 1 dayI then use this to test/check: $cookie_name = 'defaultLanguage'; if(!isset($_COOKIE[$cookie_name])) { print 'Cookie with name "' . $cookie_name . '" does not exist...'; } else { print 'Cookie with name "' . $cookie_name . '" value is: ' . $_COOKIE[$cookie_name]; }If I clear my browser cookies, this is what happens: On initial page load it says: Cookie with name "defaultLanguage" does not exist... If I reload the page or move to another, it says: Cookie with name "defaultLanguage" value is: English If I then complete my form, ?language=French is added to the URL, however, it still says: Cookie with name "defaultLanguage" value is: English I think I' missing something obvious but can't see for looking!! Any help is much appreciated I've had to rearrange a lot of code and I've been trying to put together a prepared statement in a registration form. I'm having a really hard time and being very new to PHP the issue is really confusing for me. first, I have this function: //PROCESS DB function process_database($post) { global $table; global $conn; //THIS FUCKING THING IS DRIVING ME //check database connection if ($conn->connect_error) { return false; } else { if($statement = $conn->prepare("INSERT INTO $table (username, email, password) VALUES ( ?, ?, ? )")){ $username = $post['username']; $email = $post['email']; $password = $post['password']; $statement->bind_param("sss", $username, $email, $password); $statement->execute(); //DEBUGGING echo "Added: ".$username.", ".$email.", ".$password."<br>"; if(!$statement->execute()){ printf("Connect Failed: %s\n", $conn->connect_error); } else { echo 'fuckin ay!!!'; } //END DEBUG BLOCK } else { return false; } } return true; } The issue is very strange. I'll post the function call so it's clear: //process database actions if (!process_database($data) ) { return array( 'status' => 0, 'message' => 'Unable to process database request' ); } When I run the registration.py without process_database() everything is fine, so I'm confident in the error processing. Here's where it get weird - when I process the form Quoteecho "Added: ".$username.", ".$email.", ".$password."<br>"; is returned from the //DEBUGGING BLOCK but I also get back the error from the following if statement - "Connection Failed: ...." BUT I also get back the registration successful message that only shows if the function returns true In short, it's giving me 2 positive affirmations but also the Connection failed message and of course it's not adding anything to the database. I've been working this function all day, and I'm lost for answers. What's going on with this code? I can't see where I've gone wrong Edited July 1 by TechnoDiverHi there I'm trying to insert audi files' records into mysql database this is how the records insertion looks like: Code: [Select] $fileName = $_FILES['uploaded']['name'];//name $tmpName = $_FILES['uploaded']['tmp_name'];//temp location $fileSize = $_FILES['uploaded']['size'];//size of the file $fileType = $_FILES['uploaded']['type'];//type of file $error = $_FILES['uploaded']['error'];//verifys errprs $ext = substr($fileName, strrpos($fileName, '.') +1); //this will get the extention out of the file name e.g. .mp3 //check that a file is passed by and no errors if(isset($fileName) && $error == 0 && $fileSize != 0){ //condition to accept only certain file types/extentions if($ext == "mp3" || $ext == "wma" || $ext == "wav"){ //get file content $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } //query to retrieve user's id $userid = mysql_query("select userID from user where username = '$username'"); //to get id by username $row = mysql_fetch_assoc($userid); $userid = $row['userID']; $query = "INSERT INTO tracks (trackName, userID, tag, price, file, fileName, fileSize, fileType) VALUES ('$tname','$userid','$tag','$price','$content','$fileName','$fileSize' , '$fileType)"; mysql_query($query) or die (mysql_error()); when i send it i get this error: Unknown column 'application' in 'field list' i did set data type for the fileType field to varchar. when i remove the fileType all together the record is inserted successfully into database though. ?!! can anyone help please Hi phpfreaks, please I have being working on a media site for few months now and I have designed everything that needs to be designed but A♏ having problems with my uploading code its not storing the file size in the database, I have tried and tried and all what have being doing seem to be taking me away from the right way with my little understanding of php. Here is the code that is giving me headache , <?php //include("includes/sess.php"); ?> <?php $upload="active"; include("includes/mheader.php"); ?> <?php if(isset($_POST['Upload'])) { ////////////////////////////////// //$id=$_POST['id']; $picture=$_POST['picture']; $artiste=$_POST['artiste']; $title=$_POST['title']; $genre=$_POST['genre']; $uname=$_POST['uname']; if($title=="") { $message="unknown Title"; header("location:upload.php?message=$message"); exit(); } if($genre=="") { $message="unknown Type"; header("location:upload.php?message=$message"); exit(); } /*if($nfile=="") { $message="file not found"; header("location:upload.php?message=$message"); exit(); } */ if($uname=="") { $message="error you"; header("location:upload.php?message=$message"); exit(); } if($artiste=="") { $message="Artiste ?"; header("location:upload.php?message=$message"); exit(); } header("location:upload.php?message=$message"); ////////////////////////////////// $size=$_FILES["picture"]["size"]; $file_size1 = $size/1024 ; $file_size = $file_size1/1000 ; function UploadOne($fname) { $uploaddir = 'music/NaijaMp3_'; if (is_uploaded_file($fname['tmp_name'])) { $filname = basename($fname['name']); $uploadfile = $uploaddir . basename($fname['name']); if (move_uploaded_file ($fname['tmp_name'], $uploadfile)) $res = "File " . $filname . " was successfully uploaded and stored.<br>"; else $res = "Could not move ".$fname['tmp_name']." to ".$uploadfile."<br>"; } else $res = "File ".$fname['name']." failed to upload."; return ($res); } ?> <?php if ($_FILES['picture']['name'] != "") { $res = UploadOne($_FILES['picture']); $filname = $_FILES['picture']['name']; $filname=addslashes($filname); ///////////////////////////////////////////////////////////// $alt_file_name = "NaijaMp3_" .$filname ; $date_created=date("Y-m-d h:i:A"); include("includes/db_connect.php"); $sql="INSERT INTO upmp3(uname,file_name,alt_file_name,file_size,artiste,title,genre,date_created) VALUES('$uname','$filname','$alt_file_name','$file_size','$artiste','$title','$genre','$date_created')"; mysql_query($sql) or die (mysql_error()); $message="Upload Sucessful"; ///////////////////////////////////////////////////////////// echo ($res); } } ?> <div class="main_but"> </div> </div> <!-- Navigation begins here --> <!-- Header section ends here --></div> <div class="login"> </div> <div id="feature"> <blockquote/> <div align="center"><em><strong>UPLOAD FILE </strong></em></div> <form action="upload.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <p> <br /> </p> <p>{Note: All * fields are Mandatory} </p> <p> <label> <input name="picture" type="file" id="picture" /> </label> </p> <p>File Type <label> <select name="type" id="type"> <option value="mp3">mp3</option> </select> </label> </p> <p>Artiste*<span class="style1"><sub>(e.g Alashine)</sub></span> <label> <input name="artiste" type="text" id="artiste" /> </label> Title <label> <input name="title" type="text" id="title" /><span class="style1"> </label> <p>Genre <label><input name="genre" type="text" id="genre" />(Genre e.g Hiphop, RnB, Reggae . . .)</span></label> <input type='hidden' name='id' value='<?php echo"$id" ?>' id='id'/> <input type='hidden' name='uname' value='<?php echo"$uname" ?>' id='uname'/> <label></label> </p> </p> <p> <label> <input name="Upload" type="submit" id="Upload" value="Upload Mp3" /> </label> </p> </form> </div> </div> <?php include("includes/footer.php"); ?> </div> Thanks for your help in anticipation Can't figure out what is wrong with my function getVars here is my code Code: [Select] <?php echo"<?xml version=\1.0\"encoding=\UFT-8\"\x3f>"; echo"\n"; ?> <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtmll/DTD/xhtmll-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"lang="en"> <head> <title>My third PHP Generated Document</title> </head> <body> <h2> My Third PHP Document </h2> <?php echo "<h3>Today is ".date('l, F d, Y')."</h3>"; ?> <?php //calculate the area of an equilateral triangle function calcTriangle($cVal) { $halfSide = $cVal/2; $otherSide = sqrt(($cVal*$cVal) - ($halfSide*$halfSide)); $area = $otherSide * $halfSide; echo "<p>The area of an equilateral triangle whose sides are {$calcValue} is {$areaValue}.</p>\n"; } //calculate the area of a circle function calcCircle($cVal) { $areaValue = $calcValue * $calcValue * pi(); echo "<p>The area of a circle whose radius is {$calcValue} is {$areaValue}.</p>\n"; } //calculate the area of s square function calcSquare($cVal) { $areaValue = $calcValue * $calcValue; echo "<p>The area of a square whose sides are {$calcValue} is {$areaValue}.</p>\n"; } //function to test variables function testVars() { global $_POST; if (empty($_POST['vfld'])) { echo "<h3>Error</h3>"; echo "<p>You must enter a value!</p>\n"; return "no"; } else { return "yes"; } } //function to get variables function getVars(&$a, &$b, &$c) { global $_POST; $a->$workValue = $_POST['vfld']; $b->$workType = $_POST['tfld']; $c->$calcValue = (float) $workValue; return; } $workValue = (isset($_POST['vfld']))?$_POST['vfld']:''; $workType = (isset($_POST['tfld']))?$_POST['tfld']:''; if (isset($_POST['submit'])) { if ($_POST['submit'] == "Clear") { clearVars(); } elseif ($_POST['submit'] == "Calculate") { getVars(); $continue = testVars(); if ($continue == "yes") { switch ($workType) { case "circle": calcCircle($workVal); break; case "square": calcSquare($workVal); break; case "triangle": calcTriangle($workVal); break; } } } } <form method="post" action="hw06.php" id="form1" name="form1"> <p> Enter a number here : <input type="text" id="vfld" name="vfld" value="<?php echo $workValue; ?>"/> </p> <p> This number is: <br /> <input type="radio" name="tfld" value="circle" <?php if ($workType == "circle") { echo 'checked="checked"'; } ?> /> : the radius of a circle <br /> <input type="radio" name="tfld" value="square" <?php if ($workType == "square") { echo 'checked="checked"'; } ?> /> : the length of one side of a square <br /> <input type="radio" name="tfld" value="triangle" <?php if ($workType == "triangle") { echo 'checked="checked"'; } ?> /> : the length of one side of an equilateral triangle </p> <p> <input type="submit" name="submit" value="Calculate" /> <input type="submit" name="submit" value="Clear" /> </p> </form> <div id="footer"> </div> </body> </html> and here are my errors Warning: Missing argument 1 for getVars(), called in /studfs1/homepage/CISS-225/hw06.php on line 69 and defined in /studfs1/homepage/CISS-225/hw06.php on line 55 Warning: Missing argument 2 for getVars(), called in /studfs1/homepage/CISS-225/hw06.php on line 69 and defined in /studfs1/homepage/CISS-225/hw06.php on line 55 Warning: Missing argument 3 for getVars(), called in /studfs1/homepage/CISS-225/hw06.php on line 69 and defined in /studfs1/homepage/CISS-225/hw06.php on line 55 Notice: Undefined variable: workValue in /studfs1/homepage/CISS-225/hw06.php on line 57 Fatal error: Cannot access empty property in /studfs1/homepage/CISS-225/hw06.php on line 57 Any help would be greatly appreciated please explain too Hello, I'm Dustin I going back to school for software development. this semester I am taking PHP and Javescript.
I just decided to start up on OOP, and it seems quite fun (yes, I find programming fun). But, I'm having trouble on this test OOP page. This is suppose to return the private variable $name, and if it's empty, it's suppose to echo the no name to return message. Code: <?php class findName { private $name; public function setName($sname) { if(!$sname) { $this->name = "There is no name to return."; } else { $this->name=$sname; } } public function getName() { return $this->name; } } $n = new findName(); $n->getName(); ?> If there is an easier way to do this, please let me now! Hi, I am wanting to build a small internal web portal, hopefully in php, however I just want to check that I can do a few key things before I go down this road. This is for work, so rather than waste a bunch of time, I've got a few quick questions hopefully someone can answer for me. 1) Is it possible to grab NT login information such as NTSID, Domain username, Full name based on domain login 2) show/hide objects based on above login The portal is meant to be a front end access to a bunch of reports, and the ntsid and username are used as authentication for these reports. The idea is that a user navigates to the site, it says Hi John, here are the reports you have access to. The only part I really need to worry about is the hiding and showing of the reports, since they have their own built in security. I'll also want to have an add user page, which will mean i'll need a button that grabs an ntsid based on a username entered in a field. Are these things possible? Regards, Matt I have a copy of the Developer's Library book PHP and MySQL Web Development. It teaches PHP 5.3 and MySQL 5.1. It is an extensive book of almost 1000 pages. I know that PHP is now at 5.5, but is this still good enough to learn the basics or are there major differences?
Thanks.
Hello everybody, I'm Nishio and I started to program like a month ago, my basic idea was to be able to create websites and to work as a freelancer, I know HTML and CSS from what I can design a simple website, but most of the people who look for freelancers also look for PHP/ASP knowledge, and I know some basics of PHP, like variables, booleans and NULL, constants, arrays, if statement, but I don't know how to acctualy do anything a little more complex with it. So I guess what I am asking for is a mentor, somebody who would tell and show me how do I connect PHP with web design I already know. And no I do not have any money, so I am basicly asking for somebody who has nothing to do for 1/2 hours a day and knows PHP. Thanks in advance, and sorry if I posted in a wrong section.
I know this function will get one result, I suspect foreach is the wrong loop to use, should I be using a loop at all? Can someone correct me please. public function getSites($site) { $sql = "SELECT * FROM website WHERE website_id = ?"; $stmt = $this->connect()->prepare($sql); $stmt->execute($site) $siten = $stmt->fetch(); foreach ($siten as $row) { $title = $row["website_title"]; $wname = $row["website_name"]; $image1 = "header.jpg"; $metadesc = $row["website_description"]; $wurl = $row["website_url"]; $gtag = $row["website_gtag"]; $gmap = $row["website_map"]; $wcss = $row["website_css"]; } } Edited February 23 by guymclarenza When I say I'm a noobie, I'm not kidding!
I'm using a hosting service (Bluehost) that offers PHP 5.4.30 and mySQL 5.5.37 and am trying to work through a beginners tutorial. Using the service's PHPMyAdmin tool, I have no trouble creating a database and table that I can manipulate using this tool. My problem is with my very first php command:
$db = new mysqli(localhost, 'me', 'pw', 'RR');
'me' and 'pw' are my Bluehost signon credentials that were also required to get into the PHPMyAdmin tool. 'RR' is the actual name of the database I'd created. I'm not sure if these are what mySQL is looking for. I also tried 'root' and a null password as done in the tutorial, but that didn't help. The message I get is:
Connect failed: Access denied for user 'me'@'localhost' to database 'RR'
I'd love to get somewhat proficient on PHP/mySQL. Please help.
At the moment I have <input type="hidden" name="iput-time1" value="2021-06-21 01:00"> and the time gets put in the script by $IpTime= $_POST['iput-time1']; So how can I get the time that I would put in <td>01:00</td> and do away with the hidden input bit. I have no idea even if I explained that right Hey sorry that I am asking this question, though I have gotten around to learn connecting to a database and also do the retrieve, yet I am not necessarily getting to learn doing INSERT, UPDATE and DELETE the proper way.
The tutorials available are often not best, I have found a good book ("Object Oriented Programming in PHP5") which teaches SELECT, yet not necessarily INSERT, UPDATE and DELETE.
I am really wondering how does one get to learn CRUD with PHP OOP, how did you people learn this? How can I learn INSERT, UPDATE and DELETE as well with PHP OOP? I feel like paying for this on Elance or Fiverr. I am not sure how else to learn this by now, I have tried quite a bit, I have looked at scripts and tutorials and books. And it has just gotten as far as connecting to the database and doing the "fetching" ("SELECT", or also "retrieve"). Too bad that what is available is not necessarily best. Otherwise I would say one could understand the principle quickly and also pick up on a programming language quickly. Please bear with me, I would appreciate suggestions. Hey people!
I'm new here and I desperately need your help! I have my PHP exam on monday so I'm practicing with codeacademy. I know it's easy stuff for you, but don't judge and help a girl out please!
These are the instructions:
Create a class called Cat.
Add two public properties to this class: $isAlive ought to store the value true and $numLegsshould contain the value 4.
Add a public $name property, which gets its value via the__construct()or.
Add a public method calledmeow(), which returns "Meow meow".
Create an instance of the Catclass, which has the $name "CodeCat".
Call the meow() method on thisCat and echo the result.
This is my code:
<?php Hi, everyone.
I'm having some trouble finding tutorial projects for PHP Functions. Can anyone point me in the right direction if you know of any? I apologize if this is the wrong category to post in for my particular question.
HI, I'm new to PHP and I'm trying to learn what sessions are and how they work. I'm working on a login page, I have a table in mysql for sessions, and I have a table with users that includes an email address and password. I just want to query the db to see if there is a user with that email, check the password, and start a session. Every "tutorial" i've looked at fails to answer how the session gets stored in the db, what variable I should set the session at to pull a user's information, and how to use that session to actually echo the information. I'm really frustrated and lost so if anyone knows the correct code or can explain the questions I mentioned above I would appreciate it alot. Thanks! |