Jump to content

Search the Community

Showing results for tags 'if else'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 9 results

  1. 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!
  2. 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!
  3. I am looking to show the linking button for each row that does not have the txt 'completed' in the column 'status' here is what I started with but it is not working.... See anything wrong from this newby to PHP? <?php $count = 1;foreach($link as $row):?> if ($status != 'completed'){ <tr> <td><a href="<?php echo $row['deep_link'];?>" target="_blank"> <?php echo get_phrase('launch');?></a> </td> </tr> } <?php endforeach;?>
  4. I have the following code: <?php if(($time_now<$str) && (($post->register=="0") || ($close_reg<$time_now))) { echo $online_reg_closed_message; } else if(($str<$time_now) && (($row->register=="0") || ($auto_close_reg<$time_now))) { echo $reg_closed_message; } else { echo $final_message; } ?> I checked the values of the variables and they come back as this (shortened to significant values only for clarity: $auto_close_reg 84340 $time_now 70164 (at the time of testing, at any rate) $str 66400 $close_reg 16000 $post->register 0 Now, if the logic is functioning correctly I should (at the time of testing) be seeing the message stored in$reg_closed_message displayed. I'm not. I'm seeing $final_message. It's probably something obvious but I can't see it. What did I do wrong here? Thank you.
  5. Hi guys i am busy playing around with php if statements. The code below works fine as it is but I am having problems trying to gt it to work inside an input field please help <?php $number1 = "01234"; $number2 = "012345"; if($number1 != $number2) { //if they don't match output the following echo "info do not match. Please try again."; }else{ //if they match output the following echo "Info matched Successfully!"; exit(); } ?> Now how do I tweak my above php code to incorporate the code above for easy input into fields? $number1 = "01234"; $number2 = "012345"; Please help? <form method="post" name="change"> <p>Number 1 Info<br /> <input type="text" name="number1" /> </p> <p>Number 2 Info<br /> <input type="text" name="number2" /> </p> <p> <input name="submit" type="submit" value="Check if they match" /> </p> </form>
  6. i have been working on minor project this is login script of that page i am facing some problem i want to echo if user name password and category both 3 conditions dont match with error "wrong username/password" in form i have tried everything as per my knowledge please help me in this i am new to php so dont have much experience and knowledge of php <?php $msg=''; $con=mysql_connect('localhost','root',''); if(!$con) { die("Error While connecting......."); } else { mysql_select_db("sms",$con); if(isset($_POST['btnlog'])) { $res=mysql_query("select * from tbl_login where un='".$_POST['username']."' and pw='".$_POST['password']."' and cat='".$_POST['cat']."'"); while($r=mysql_fetch_array($res)) { mail("notification@receiver.com".$_POST['username']."Successfully Logged In"."From:notification@sender.com"); if($r['cat']=="admin") header("Location:admin/admin.php"); elseif($r['cat']=="faculty") header("Location:faculty/faculty.php"); else $msg="Incorrect Username/Password"; } } } ?> <body> <section class="login_container"> <div class="login_box"> <h1>Login</h1> <form method="post"> <center><?php echo $msg; ?></center> <p><input type="text" name="username" value="" placeholder="Username"></p> <p><input type="password" name="password" value="" placeholder="Password"></p> <center><select class="select" name="cat">Category <option selected="selected">Select A Category</option> <option value="admin">Administrator</option> <option value="faculty">Faculty</option> </select></center> <p class="submit"><input type="submit" name="btnlog" value="Login"> <input type="reset" value="Clear" /></p> </form> </div> </section>
  7. Hi I need to make a form whereby it is being controlled by a radio button. I already make it to work the way I want, with just 1 problem i faced. I need to make it in such a way that: if radio1 is clicked, it will show radio7, radio8, radio9 and radio10. if radio2 is clicked, it will show radio7, radio8, radio9 and radio10. if radio3 is clicked, it will show radio8, radio9 and radio10. if radio4 is clicked, it will show radio9 and radio 10. I have already achieved the code above on how i want it to show accordingly. The problem arises when I clicked on radio2, i want to deselect all option from any radio and default select the first option; either radio7, radio8 or radio9 accordingly. Currently, if i select radio3, the option will still be from radio2. This is not what i want. Any suggestion? Attached are my working files. 111.php style.css radio-image.css
  8. Can anybody help me to check what's wrong with the coding. First, i get the value of checkbox from the previous page. So, if checkbox 1 and 2 is selected, result with result_id 4 will be shown. if checkbox 1 and 3 is selected, result with result_id 5 will be shown. Now the problem is...no matter which checkbox is selected, the program will only run 'if statement' , which is result_id 4. Below is the coding. Hope you guys can help me. >< .Thank alot!! <?php session_start(); if(isset($_GET['checkbox'])){ $checkbox = $_GET['checkbox']; } else { header('Location:tutorial.php'); } include("database.php"); for($i=0; $i < count($checkbox); $i++){ { if ($checkbox[$i]= '1' && $checkbox[$i]= '2'){ $sql="SELECT * FROM result WHERE result.result_id = 4";} elseif ($checkbox[$i]='1' && $checkbox[$i]= '3'){ $sql="SELECT * FROM result WHERE result.result_id = 5";} else {} } } $result=mysql_query($sql); echo "<form action = 'result.php' method='POST'> <br/>"; echo "<table>"; while($row = mysql_fetch_array($result)) { $result_name=$row['result_name']; $result_id=$row['result_id']; $result_desc=$row['result_desc']; $image=$row['image']; echo "<h4>$result_name</h4> "; echo "<tr >"; echo "<td>"; echo "</form>";?> <img src="<?php echo $row ["image"];?>" width="500" height = "600" align="left" border="1" /><?php echo "</td>" ; echo "</tr>"; } echo "</table>"; ?>
  9. I'm trying to make an If Else Statement in my while loop which that statement can read the value from what the user inserted. Each numbers have their own link which process different type of letter. Is that possible to insert 'If ... Else Statement' in my While Loop ?? because I keep getting an error message when I combine If Else inside my While Loop. But without If Else , there's no error message appear. Hope from this code you can see what I'm trying to do . <?php $host_name = "localhost"; $user_name = "root"; $password = ""; $db_name = "finalproject"; $StudentID1=$_POST['Field0']; $StudentID2=$_POST['Field1']; $StudentID3=$_POST['Field2']; $term =$StudentID1.-$StudentID2.-$StudentID3; mysql_connect("$host_name" , "$user_name" , "$password"); mysql_select_db("$db_name"); $sql = "SELECT * FROM student,surat WHERE student.student_id like '%$term%' AND student.student_id=surat.student_id"; $query = mysql_query($sql) or die("Error: " . mysql_error() . "<br />In Query: " . $sql); while ($row = mysql_fetch_array($query)){ echo 'Student ID: '.$row['student_id']; echo '<br/> Fullname: '.$row['fullname']; echo '<br/> IC No.: '.$row['ic_number']; echo '<br/> Course: '.$row['course']; echo '<br/> Type Of Letter: '.$row['jenissurat']; echo '<br/><br/>'; $jenis=$rows['jenissurat'] if($jenis=='1') { ?> <a href="PHPWord/PengesahanBelajar-code.php">Generate Letter</a> <? } else if($jenis=="2") { ?> <a href="PHPWord/KebenaranProjek-code.php">Generate Letter</a> <? } else if($jenis=="3") { ?> <a href="PHPWord/PelepasanExam-code.php">Generate Letter</a> <? } else if($jenis=="4") ?> <a href="PHPWord/TamatBelajar-code.php">Generate Letter</a><? } } ?> I also need a help to bring data of '.$row['jenissurat']; as my If Else condition.. Many of this code I copy from a website.. I'm new in PHP and Mysql ... but I MUST to complete this code without error. I already download 2 file that have connection with this code. Hope someone can give me an advice,solution or corrections maybee.. Thank You. Search.php searchres.php
×
×
  • 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.