Jump to content

jameshay

New Members
  • Posts

    7
  • Joined

  • Last visited

jameshay's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. HI, I am a beginner at programing and I have to do this project where it is asking me to valid ISBN 10 and 13 using MySQL database to store the information. I checked my php code to validate ISBN 10 and 13 and it works, but when I try to store the data to MySQL it is not working. What I mean is that when I click ShowISBN link it doesn't show this information: ISBN Number ISBN Type Date Entered using timestamp Valid or Invalid This is the codes I have for input page of ISBN page: <?php //this is the isset function which allows us to submit back //to the same form. If there isn't anything in the ISBN, it will //show the bottom part of the form if(isset($_POST["ISBN"])|| empty($_POST['isbn_type']) || empty($_POST['Valid_Invalid'])) { $ISBN = $_POST["ISBN"];; $IsbnType = $_POST["isbn_type"];; $VaorIn = $_POST["Valid_Invalid"];; $ISBN_Arr = str_split($ISBN); $not10 =0; $notNum=0; $notX=0; //entering error checking for the code //check for 10 first, if clear do additional checking if(strlen($ISBN) == 10) {//start further error checking //check to make sure first 9 are numeric for($i=0;$i<=8;$i++) { if(!is_numeric($ISBN_Arr[$i])) $notNum = 1; }//end for loop check //check to see if there is a X or a x if($ISBN_Arr[9]=='x' || $ISBN_Arr[9]=='X') { $ISBN_Arr[9] = 10; } //if not an x, is it at least numeric? else if (!is_numeric($ISBN_Arr[9]) ) { $notX=1; } }//end additional error checking else { $not10=1; }//end not 10 check //start of error messages if prereqs are not met if($notNum ==1 || $notX ==1 || $not10) { Print "<h2>Input error</h2><br/>"; Print "Here is the error(s) discovered:<br/>"; if($notNum ==1) print"Your ISBN contains non-numeric data.<br/>"; if($notX ==1) print"The last digit is not a number or a X.<br/>"; if($not10 ==1) print"ISBN 10 number should contain 10 characters.<br/>"; include"ISBN_not_val_include.html"; } //end error checking else{ $chk_sum_num=10; $chk_sum =0; for($i=0;$i<=9;$i++) { $chk_sum +=$ISBN_Arr[$i] *$chk_sum_num; //print"$ISBN_Arr[$i] | $chk_sum_num<br/>"; $chk_sum_num--; }//end for loop $is_valid_ISBN= $chk_sum%11; //print"chk_sum: $chk_sum </br> is_valid_ISBN: $is_valid_ISBN</br>"; if($is_valid_ISBN==0) { print"<h3>VALID</h3><br/>"; print"$ISBN is a VALID 10 digit ISBN number.<br/>"; include"ISBN_val_include.html"; } else{ print"<h3>INVALID</h3><br/>"; print"$ISBN is an INVALID 10 number ISBN.<br/>"; include"ISBN_not_val_include.html"; }//end is_valid if }//end }//end is set if else{ include"ISBN_val_include.html"; }//end isset else ?> </form> <p><a href="_ShowISBN10and13DBProject.php">Show ISBN </a></p> </body> </html> This is the second part of the code that incorporates php and MySQL: <?php if (empty($_POST['ISBN'])|| empty($_POST['isbn_type']) || empty($_POST['Valid_Invalid'])) echo "<p>You must enter a Valid ISBN 10 to Continue! Please Click your browser's Back Button to return to the input page of ISBN 10 with Database.</p>\n"; else { $DBConnect = @mysql_connect("xxx.xxx.xx.xxx", "xxxxxxxx", "xxxxxxxx"); if($DBConnect === false) echo"<p>Unable to conenct to the database server.</p>" . "<p>Error code " . mysql_errno() . ": " . mysql_error() . "</p>"; else{ $DBName = "xxxxxxxx"; if (!@mysql_select_db($DBName, $DBConnect)) { $SQLstring = "CREATE DATABASE $DBName"; $QueryResult = @mysql_query($SQLstring, $DBConnect); if ($QueryResult === FALSE) echo "<p>Unable to execute the query.</p>" . "<p>Error code " . mysql_errno($DBConnect) . ": " . mysql_error($DBConnect) . "</p>"; else echo "<p>You are the first visitor!</p>"; } mysql_select_db($DBName, $DBConnect); $TableName = "isbn"; $SQLstring = "SHOW TABLES LIKE '$TableName'"; $QueryResult = @mysql_query($SQLstring, $DBConnect); if ($QueryResult === FALSE) echo "<p>Unable to create the table.</p>" . "<p>Error code " . mysql_errno($DBConnect) . ": " . mysql_error($DBConnect) . "</p>"; $ISBNum = stripslashes($_POST['ISBN']); $ISBNType = stripslashes($_POST['isbn_type']); $VaORIn = stripslashes($_POST['Valid_Invalid']); $SQLstring = "INSERT INTO $TableName VALUES(NULL, '$ISBNum', '$ISBNType', '$VaORIn')"; $QueryResult = @mysql_query($SQLstring, $DBConnect); if($QueryResult === false) echo"<p>Unable to execute the query.</p>" . "<p>Error code " . mysql_errno($DBConnect) . ": " . mysql_error($DBConnect) . "</p>"; else echo"<h1>Thank you for trying our ISBN 10 program!</h1>"; mysql_close($DBConnect); } } ?><!--End PHP Script--> This is the page where it is not working! <?php $DBConnect = @mysql_connect("xxx.xxx.xx.xxx", "xxxxxxx", "xxxxx"); if($DBConnect === false) echo"<p>Unable to conenct to the database server.</p>" . "<p>Error code " . mysql_errno() . ": " . mysql_error() . "</p>"; else{ $DBName = "xxxxxx"; if (!@mysql_select_db($DBName, $DBConnect)) echo"<p>There are no entries in the guest book!</p>"; else { $TableName = "isbn"; $SQLstring = "SELECT * FROM $TableName"; $QueryResult = @mysql_query($SQLstring, $DBConnect); if (mysql_num_rows($QueryResult) == 0) echo"<p>There are no entries in the ISBN 10 Database!</p>"; else{ echo"<p>The following ISBN have been recorded:</p>"; echo"<table width='100%' border='1'>"; echo"<tr><th>ISBN Number</th><th>ISBN Type</th><th> Date Entred</th><th> Valid OR Invalid</th></tr>"; while (($Row = mysql_fetch_assoc($QueryResult)) !==FALSE) { echo "<tr><td>{$Row['ISBN']}</td>"; echo "<tr><td>{$Row['isbn_type']}</td>"; echo "<tr><td>{$Row['TIMESTAMP']}</td>"; echo "<td>{$Row['Valid_Invalid']}</td></tr>"; } } mysql_free_result($QueryResult); } mysql_close($DBConnect); } When I click show ISBN nothing happens and I am not shore why! This is how I have my table setup in MySQL Manually by clicking table and create table: Columns: count int(11) Al PK ISBN varchar(45) isbn_type varchar(45) TIMESTMP datetime PK Valid_Invalid varchar(45) Can someone please tell me why when I click Show ISBN in the input page the first code pasted I get nothing! How do I fix the issue because my validation works, but it's not storing it or showing up when click Show ISBN! Any help will be appreciate it!
  2. HI, I am a beginner at programing and I have to do this project where it is asking me to validate any ISBN 13 number. I know how to set up the input page, but I am having or you could say no Idea how to validate a number if user inputs data in the input page. I have some could below that I think it should be included, but if someone has better way to do it then I would be appreciate it. here is the input page code: <form method="POST" action="Process_isbn13.php"> <p>Enter the ISBN 13: <input type="text" name="isbn13"/></p> <input type="submit" name="Submit" value="Submit" /> </form> I have this so far for my processing page to validate the ISBN 13 number! <?php function isValidISBN13($isbn) { $sum = 0; for ($i = 0; $i < 13; $i++) { if ($isbn[$i] === 'X') { $value = 13; } else { $value = $isbn[$i]; } $sum += ($i + 1) * $value; } } ?> I know there should be more like if it is empty it should say it's empty do it again and if it is not validate then it would say that. The most important thing I need is the code so if i enter a validate ISBN 13 number it would say it's validate! Someone please help me with the code needed to check if ISBN 13 number is validate.
  3. This is the project I need to finish. I am fairly new to php and this project has got me confused. Any help would be greatly appreciated The project ask for to validate ISBN 10 Number. There would be 10 digits with 1-9 being Numbers, but Number 10 is an x. This is What I have so far: This is the input page or html page: <form method="POST" action="Process10ISBN.php"> <p>Enter ISBN 10: <input type="text" name="isbn10" /></p> <input type="submit" name="Submit" value="Submit" /> </form> This is what I have so far for the Procssing page to validate ISBN 10: <?php if (empty($_POST['isbn10'])) echo "<p>Please Fill in the input fields. Please use the back button to re-enter the data!</p>\n"; else { $ISBN10 = addslashes($_POST['isbn10']); echo "<p>Thank you for your input!</p>\n"; } //this are the code that should go in the project $chk_sum_num=10; for($i=0;$i<=9;$i++ { $chk_sum+=$ISBN_Arr[$i] * $chk_sum_num; print"$ISBN_Arr[$i] | $chk_sum_num<br/>"; $chk_sum_num--; }//end for loop //this goes at top, then the loop goes inside it If $ISBNARR[9]!=is numeric{{!= 'X'!!='x' print"Not ISBN 10 Number<br/>"; Else If $ISBNARR[9]=='x' or "X" $ISBNARR[9] = 10 ?><!--End PHP Script--> // I don't know how to set up the processing page. All I know is that this code has to be included in the processing page: I know my processing code is set up wrong. I couldn't figure out how I would put the codes in and what else I needed to add! //this are the code that should go in the project $chk_sum_num=10; for($i=0;$i<=9;$i++ { $chk_sum+=$ISBN_Arr[$i] * $chk_sum_num; print"$ISBN_Arr[$i] | $chk_sum_num<br/>"; $chk_sum_num--; }//end for loop //this goes at top, then the loop goes inside it If $ISBNARR[9]!=is numeric{{!= 'X'!!='x' print"Not ISBN 10 Number<br/>"; Else If $ISBNARR[9]=='x' or "X" $ISBNARR[9] = 10 ?><!--End PHP Script--> Can Someone show me how I am suppose to do the processing page for my ISBN 10 validation! Thank You!
  4. This is the project I need to finish. I am fairly new to php and this project has got me confused. Any help would be greatly appreciated I am trying to do a Web form that is taking an online order form! This is What I have so far: This is the input page or html page: <form method="POST" action="OnlineOrders.php"> <table border=0> <tr> <td width=260>NameE<br /></td> <td width=295>Descripation<br /></td> <td width=45>Price<br /></td> <td width=35>Quanity<br /></td> </tr> <tr> <td>Shirts</td> <td>Red</td> <td align="right">$11.50</td> <td align="center"><input type="text" name="shirt" size="3" maxlength="3" /></td> </tr> <tr> <td>Pants</td> <td>blue</td> <td align="right">$23.99</td> <td align="center"><input type="text" name="pants" size="3" maxlength="3" /></td> </tr> <tr> <td>Shoes</td> <td>Tennis Show</td> <td align="right">$35.25</td> <td align="center"><input type="text" name="shoes" size="3" maxlength="3" /></td> </tr> <tr> <tr> <td>Coat</td> <td>Winter coat</td> <td align="right">$47.50</td> <td align="center"><input type="text" name="coat" size="3" maxlength="3" /></td> </tr> <tr> <td>Socks</td> <td>Yellow</td> <td align="right">$4.99</td> <td align="center"><input type="text" name="socks" size="3" maxlength="3" /></td> </tr> <tr> <td>Hats</td> <td>Baseball Cap</td> <td align="right">$8.99</td> <td align="center"><input type="text" name="hats" size="3" maxlength="3" /></td> </tr> </tr> </table> </form> <br /> <input name="submit" type="submit" value="Submit Order" /> <input type="reset" name="reset" value="Recalculate Order" /> <hr /> <p> <a href="OrderBoard.php">View Order</a> </p> </body> </html> ******************** The problem is I don't know what to do with the processing page for me to do the rest: I am taking about OnlineOrders.php that i have at the beginning of the program: <form method="POST" action="OnlineOrders.php"> How do i start the Processing page of the program! Can Someone show me how do I start and I could do the rest! Thank You!
  5. I can't figure out what's wrong with this. The program works, but the duplication doesn't work. The error I get is : Notice: Undefined variable: SongToAdd in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 6\R.E.6-1_SongOrganizer.php on line 64 Notice: Undefined variable: ExistingSongs in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 6\R.E.6-1_SongOrganizer.php on line64 Warning: in_array() expects parameter 2 to be array, null given in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 6\R.E.6-1_SongOrganizer.php on line 64 Warning: fopen(SongOrganizer/songs.txt): failed to open stream: No such file or directory in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 6\R.E.6-1_SongOrganizer.php on line 72 There was an error saving your message! I bolded line 64 below, which is an if (in_array ) statement. line 64 is: if (in_array($SongToAdd, $ExistingSongs)) { echo "<p>The song you entered already exists!<br />\n"; echo "Your song was not added to the list.</p>"; } <?php if (isset($_GET['action'])) { if ((file_exists("SongOrganizer/songs.txt")) && (filesize("SongOrganizer/songs.txt") != 0)) { $SongArray = file("SongOrganizer/songs.txt"); switch ($_GET['action']) { case 'Remove Duplicates': $SongArray = array_unique($SongArray); $SongArray = array_values($SongArray); break; case 'Sort Ascending': sort($SongArray); break; case 'Shuffle': shuffle($SongArray); break; } // end of switch statement if (count($SongArray)>0) { $NewSongs = implode($SongArray); $SongStore = fopen("SongOrganizer/songs.txt", "wb"); if ($SongStore === false) echo "There was an error updating the song file\n"; else { fwrite($SongStore, $NewSongs); fclose($SongStore); } } else unlink("SongOrganizer/songs.txt"); } } if (isset($_POST['submit'])) { $SongToAdd = stripslashes($_POST['SongName']) . "\n"; $ExistingSongs = array(); if (file_exists("SongOrganizer/songs.txt") && filesize("SongOrganizer/songs.txt") > 0) { $ExistingSongs = file("SongOrganizer/songs.txt"); } } if (in_array($SongToAdd, $ExistingSongs)) { echo "<p>The song you entered already exists!<br />\n"; echo "Your song was not added to the list.</p>"; } else { $SongFile = fopen("SongOrganizer/songs.txt", "ab"); if ($SongFile === false) echo "There was an error saving your message!\n"; else { fwrite($SongFile, $SongToAdd); fclose($SongFile); echo "Your song has been added to the list.\n"; } } if ((!file_exists("SongOrganizer/songs.txt")) || (filesize("SongOrganizer/songs.txt") == 0)) echo "<p>There are no songs in the list.</p>\n"; else { $SongArray = file("SongOrganizer/songs.txt"); echo "<table border=\"1\" width=\"100%\" style=\"background-color:lightgray\">\n"; foreach ($SongArray as $Song) { echo "<tr>\n"; echo "<td>" . htmlentities($Song) . "</td>"; echo "</tr>\n"; } echo "</table>"; } ?> <!-- Display hyperlinks for the three functions in the switch statement (Sort Ascending, Remove Duplicates, and Shuffle) --> <p> <a href="SongOrganizer.php?action=Sort%20Ascending">Sort Song List</a><br /> <a href="SongOrganizer.php?action= Remove%20Duplicates">Remove Duplicate Songs</a><br /> <a href="SongOrganizer.php?action=Shuffle"> Randomize Song List</a><br /> </p> <!-- web form for entering new song names into the song list: --> <form action="SongOrganizer.php" method="post"> <p>Add a New Song</p> <p>Song Name: <input type="text" name="SongName" /></p> <p><input type="submit" name="submit" value="Add Song to List" /> <input type="reset" name="reset" value="Reset Song Name" /></p> </form> Any help would be appreciated!
  6. I am new to PHP and I am having some problems and I am hoping someone can point me in the right direction. Here is what I need to do: Create a Web Form for uploading pictures for a high school reunion. The form should have text input fields for the person's name and a description of the image, and a file input field for the image. To accompany each file, create a text file that contains the name and description of the image. Create a separate Web Page that displays the pictures with a caption showing the name and description fields. Make sure the folder has read and write for everyone. Here is what I have but it isnt working properly: Process page of the page! an errow here: This is the message I get! Parse error: syntax error, unexpected '\' (T_NS_SEPARATOR) in C:\ITEC315\htdocs\users\ramojumder0\Reinforcement Exercises\Ch. 5\R.E.5-5_FillPictureForm.php on line 28 which deals with the picture! My problem is that it is having a problem uploading a picture and showing it! How do I fix the issue with uploading a picture and then showing it! Input page <form method="POST" action="R.E.5-5_Fillrrr.php"> <p>Name <input type="text" name="name" /></p> <p>Description <input type="text" name="description" /></p> <p>Choose a file to upload: <input type = "file" name = "picture" accept = "image/*" /></p> <p><input type="submit" value="Submit" /></p> </form> <p><a href="R.E.5-5_ShowPictures.php">Show Pictures </a></p> </body> </html> Processing page! <?php if (empty($_POST['name']) || empty($_POST['description'])) echo "<p>You must enter your name and description about your picture. Click your browser's Back button to return to the Picture Input Page!</p>\n"; else { $Name = addslashes($_POST['name']); $Description = addslashes($_POST['description']); $Picture = addslashes($_POST['picture']); $ShowPic = fopen("showpic.txt", "ab"); if (is_writeable("showpic.txt)) { if (fwrite($ShowPic, $Name . "," . $Description . "," . $Picture . "\r\n")) echo "<p>Thank you for filling out the Picture Input Page!</p>\n"; else echo "<p>Cannot add your name to the Picture Input Page!</p>\n"; } else echo "<p>Cannot write to the file.</p>\n"; fclose($ShowPic); } ?><!--End PHP Script-->
  7. Hi,I am a beginner in php. And I am trying to create this php program where a user selects a picture and it displays it! Theare is an input page which is html and an processing page which is php! I seemes to have a problem in the processing page of the program. The problem is on line 22 in the processing page and it relates to escape character. How do I fix my issue please help I alredy spend more the several hours on it and still can't figure it out! Here are the code for the processing page: <?php if(isset($_POST['Random'])) { $Random = rand(0,12)." .jpg"; Print "<img src=\ "Photos/$Random\" alt="Smiley face"height="50%" width="50%" border="5" <br/>"; //Problem with escape character heare don't know how to fix it! } else { if (isset($_POST['Anime'])) { $Arr=$_POST['Anime']; displayPhotos($Arr); } else { echo "You need to select photo.<br />"; } function displayPhotos($Arr) { foreach ($Arr as $element) { print " <br/>"; Switch ($element){ Case 1: echo "<img src="Photos/1.jpg" alt="Smiley face" height="50%" width="50%" border="5" <br/>"; break; Case 2: echo "<img src="Photos/2.jpg" alt="Smiley face" height="50%" width="50%" border="5" <br/>"; break; Case 3: echo "<img src="Photos/3.jpg" alt="Smiley face" height="50%" width="50%" border="5" <br/>"; break; Case 4: echo "<img src="Photos/4.jpg" alt="Smiley face" height="50%" width="50%" border="5" <br/>"; break; Case 5: echo "<img src="Photos/5.jpg" alt="Smiley face" height="50%" width="50%" border="5" <br/>"; break; Case 6: echo "<img src="Photos/6.jpg" alt="Smiley face" height="50%" width="50%" border="5" <br/>"; break; Case 7: echo "<img src="Photos/7.jpg" alt="Smiley face" height="50%" width="50%" border="5" <br/>"; break; Case 8: echo "<img src="Photos/8.jpg" alt="Smiley face" height="50%" width="50%" border="5" <br/>"; break; Case 9: echo "<img src="Photos/9.jpg" alt="Smiley face" height="50%" width="50%" border="5" <br/>"; break; Case 10: echo "<img src="Photos/10.jpg" alt="Smiley face" height="50%" width="50%" border="5" <br/>"; break; Case 11: echo "<img src="Photos/11.jpg" alt="Smiley face" height="50%" width="50%" border="5" <br/>"; break; Case 12: echo "<img src="Photos/12.jpg" alt="Smiley face" height="50%" width="50%" border="5" <br/>"; break; } } } } ?><!--End PHP Script--> [b]* Can someone also look at the rest of the code and tell me whats wrong and fix it for me Thank You! Here is the input page incase anyone needs to lok at to solve the processing page codes:[/b] <i>Please click any checkboxes to select a photo!</i> <script type="text/javascript" language="javascript">// <![CDATA[ function checkAll(formName, checktoggle) { var checkboxes = new Array(); checkboxes = document[formName].getElementsByTagName('input'); for (var i=0; i<checkboxes.length; i++) { if (checkboxes[i].type == 'checkbox') { checkboxes[i].checked = checktoggle; } } } // ]]></script> <fieldset> <a onclick="javascript:checkAll('getIt', true);" href="javascript:void();">check all</a> <a onclick="javascript:checkAll('getIt', false);" href="javascript:void();">uncheck all</a><br/> <form action="Process_Page of the Project.php" method="post" name="getIt"> <input type="checkbox" name="Anime[]" value="1" />Code Geass Lelouch Of The Rebellion<br/> <input type="checkbox" name="Anime[]" value="2" />Death Note<br/> <input type="checkbox" name="Anime[]" value="3" />A Certain Magical Index<br/> <input type="checkbox" name="Anime[]" value="4" />Kaze No Stigma<br/> <input type="checkbox" name="Anime[]" value="5" />One Piece<br/> <input type="checkbox" name="Anime[]" value="6" />Trigun<br/> <input type="checkbox" name="Anime[]" value="7" />Tengen Toppa Gurren Lagann<br/> <input type="checkbox" name="Anime[]" value="8" />Prince Of Tennis<br/> <input type="checkbox" name="Anime[]" value="9" />Fairy Tail<br/> <input type="checkbox" name="Anime[]" value="10" />Katekyo Hitman Reborn<br/> <input type="checkbox" name="Anime[]" value="11" />Bleach<br/> <input type="checkbox" name="Anime[]" value="12" />Silver Spoon(Gin no Saji)<br/><br/> <input type="submit" name="formSubmit" value="Submit Choices" /> </form> </fieldset> <br/> <fieldset> <form action="Process_Page of the Project.php" method="post"> You can also click the Random button to view a random photo.<br/><br/> <button name="Random" type="submit" value="R"> Randomize Me!</button> </form> </fieldset> </p> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.