Jump to content

Search the Community

Showing results for tags 'simple'.

  • 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 10 results

  1. i am looking for simple php mysql base event calender..that shows upcoming events...i would very helpful for your help.any tutorial.video.or helping link..??
  2. Hi. I am trying to create a simple video file server. I finished the skeleton of it but when it came to creating the multitude of pages I realized that there could be an easier way to do it. I started out basically getting the folder names in the server then printing them on the page. <?php $dirs = glob("*", GLOB_ONLYDIR); echo '<ul>'; foreach($dirs as $dir) { $forbidden_folders = array("not4u", "ignore", Styles); $filename = str_replace($forbidden_folders, '', $dir); if (!empty($filename)) { echo '<li><a href="'.$dir.'">'.$dir.'</a></li>'; } } echo '</ul>' ?> Then I created in each of the folders with files a php file with this code: <?php function date_sort_desc($a, $b) { preg_match('/\w+ \d{4}/', $a, $matches_a); preg_match('/\w+ \d{4}/', $b, $matches_b); $timestamp_a = strtotime($matches_a[0]); $timestamp_b = strtotime($matches_b[0]); if ($timestamp_a == $timestamp_b) return 0; return $timestamp_a < $timestamp_b; } $files = array(); $dir = opendir('.'); while(false != ($file = readdir($dir))) { if(($file != ".") and ($file != "..") and ($file != "index.php")) { $files[] = $file; } } natsort($files); $i = 0; foreach($files as $file) { $i++; $string = str_replace("TV Show Name S1 E$i - ", '' , $file); echo '<div><a href="../Discriptions/'.$file.'.php">'.basename($string, '.m4v').'</a></div><br>'; } ?> This opens up a php file with the same file name as the file to be played containing the episode's thumbnail and description. That file then contains a link pointing back to the real file. The problem here is that I'd have to make a new php file for every file in my collection. I'm wondering if there's somehow a way to simplify all of this.
  3. Hello! I was assigned to create a simple php game as a part of my grade. I'm not really a php expert and this isnt really working. I copied some of the code from this website, but this isn't really working for me. I don't really know how to solve the problem and connect that two files. Part 1: <html> <head> <title>PHP based example Game - Earth & Wind & Fire (aka Paper-Scissors-Rock)</title> </head> <body> <center> <div id="game"> <a href="?item=earth">Earth<br /><img src="images/sand.png" width="135" height="135" alt="Earth"></a><br /><a href="?item=wind">Wind<br /><img src="images/wind.png" width="135" height="135" alt="Wind"></a><br /><a href="?item=fire">Fire<br /><img src="images/fire.png" width="135" height="135" alt="Fire"></a><br /></div> </center> </body> </html> Part 2: <?php function showComponents($items = null) { $pictures = array( "earth" => '<a href="?item=earth">Earth<br /><img src="images/sand.png" width="135" height="135" alt="Earth"></a><br />', "wind" => '<a href="?item=wind">Wind<br /><img src="images/wind.png" width="135" height="135" alt="Wind"></a><br />', "fire" => '<a href="?item=fire">Fire<br /><img src="images/fire.png" width="135" height="135" alt="Fire"></a><br />', ); if ($items == null) : foreach( $pictures as $items => $value ): echo $value; endforeach; else: echo str_replace("?item={$items}", "#", $pictures[$items]); endif; } function game() { if ( isset($_GET['item']) == TRUE ) : $pictures = array('earth','wind','fire'); $playerPic = strtolower($_GET['item']); $computerPic = $pictures[rand(0, 2)]; echo '<div><a href="http://mapswidgets.com/game.php">New game</a></div>'; if (in_array($playerPic, $pictures) == FALSE): echo "Play as either Earth, Wind or Fire."; die; endif; if ( $playerPic == 'fire' && $computerPic == 'wind' OR $playerPic == 'earth' && $computerPic == 'fire' OR $playerPic == 'wind' && $computerPic == 'earth' ): echo '<h2>You Win!</h2>'; endif; if ( $computerPic == 'fire' && $playePic == 'wind' OR $computerPic == 'earth' && $playerPic == 'fire' OR $computerPic == 'wind' && $playerPic == 'earth' ): echo '<h2>Computer wins!</h2>'; endif; if ($playerPic == $computerPic) : echo '<h2>House wins! =)</h2>'; endif; showComponents($playerPic); showComponents($computerPic); else : showComponents(); endif; } ?> Thanks for your time and help!
  4. Hi PHP Freaks! I'm one of the newer users here, yep. And this is my first post here ^.^ I have recently started working on my very simple script in PHP. Parse username/password, perform checks against array to see if username exists and if password is correct for specified user. Print out a message as a finish result. And here is what my problem is.. So far I have written this code (PHP): <?php // List of users and their password. $users = array(1 => 'admin', 2 => 'UserTwo', 3 => 'UserThree', 4 => 'UserFour'); $pass = array(1 => '1234', 2 => 'second', 3 => 'third', 4 => 'fourth'); // Compare username parameter against users list (check if user exists). if (in_array($_GET['username'], $users)) { // User is found. Compare password parameter against pass list corresponding to user ID in array. $userId = array_search($_GET['username'], $users); // Compare password parameter against pass list (using specific userId to check if password is valid). if ($_GET['password'] != $pass[userId]) { echo 'You have entered invalid password.'; } else { echo 'Welcome, '.$_GET['username'].'!'; } } else { // User is not found. echo 'You have entered invalid user name.'; } ?> I guess some of you experienced in PHP understand what I am doing up there Basically I wanted to parse username/password arguments to the URL. That works just fine ( echo $_GET['username'] . '<br>' . $_GET['password']; ) ( Just a note, I use Xampp, so it is http://localhost/login.php?username=admin&password=1234 ) Problem starts at line 9.. I am unsure about that part (I just written it out of my mind and little documentation I have found on their official website) with userId and then comparing it to correspond to the user (like like associating password to specific user id, users[0] = admin to have password 1234, users[1] , and so). Could somebody fix this and post up the code, much appreciated (excuse me for little English mistakes, it is not my native language, I do my best to keep it well) Also include a little description or just explain it in several words, what/where I messed up Thanks in advance. Regards, - OmegaExtern
  5. hello, i am new to php programming.. i need to execute this url in my send sms.php file.. i tried curl method but failed.. API URL is , sample" http://bulksms.mysmsmantra.com:8080/WebSMS/SMSAPI.jsp?username=hidden&password=hidden&sendername=iZycon&mobileno=8289947807 i just need to execute this url in my page... while replying plz include the php code..
  6. I am having trouble getting a simple form to submit data to a database. I have followed an example in a PHP/MySQL book (Welling and Thomson) and created a simple form to update a DVD collection. Right now I just have a form started and am just trying to get it to INSERT records into my database. It is making a connection to the database, but it returns my Error stating that the record could not be added. While all of my code is very basic,I am just trying to get an understanding as to how it is working... I have looked in MySQL through command prompt and the database exists, but records are not being added. I can add records to the table through CMD prompt. I will post my code for the database and my two php files for inserting records. Database: create database movie_info; use movie_info; create table movies (movieid int unsigned not null auto_increment primary key, title char(50) not null, movieyear char(4) not null, genre char(25) not null, subgenre char(25), director char(30), actor1 char(30), actor2 char(30), actor3 char(30), discs char(2), season char(2), comments char(200) ); Form: function input_form(){ ?> <form method="post" action="insert_movie.php"> <table bgcolor="#cccccc"> <tr> <td colspan="2">Enter a new DVD:</td> <tr> <td>Title:</td> <td><input type="text" name="title"/></td></tr> <tr> <td>Year:</td> <td><input type="text" name="year"/></td></tr> <tr> <tr> <td>Genre:</td> <td><input type="text" name="genre"/></td></tr> <tr> <tr> <td>Sub-Genre:</td> <td><input type="text" name="subgenre"/></td></tr> <tr> <tr> <td>Director:</td> <td><input type="text" name="director"/></td></tr> <tr> <tr> <td>Actor:</td> <td><input type="text" name="actor1"/></td></tr> <tr> <tr> <td>Actor:</td> <td><input type="text" name="actor2"/></td></tr> <tr> <tr> <td>Actor:</td> <td><input type="text" name="actor3"/></td></tr> <tr> <tr> <td>Number of discs:</td> <td><input type="text" name="discs"/></td></tr> <tr> <tr> <td>Season:</td> <td><input type="text" name="season"/></td></tr> <tr> <tr> <td>Comments:</td> <td><input type="text" name="comments"/></td></tr> <tr> <td colspan="2" align="center"> <input type="submit" value="Submit"/></td></tr> <tr> </table></form> <?php } and the INSERT code: <?php require_once('movie_functions.php'); //require_once('db_functions.php'); do_html_header('Moviebase'); @$title = $_POST['title']; @$year = $_POST['year']; @$genre = $_POST['genre']; @$subgenre = $_POST['subgenre']; @$director = $_POST['director']; @$actor1 = $_POST['actor1']; @$actor2 = $_POST['actor2']; @$actor3 = $_POST['actor3']; @$discs = $_POST['discs']; @$season = $_POST['season']; @$comments = $_POST['comments']; if (!$title || !$year || !$genre) { echo "You have not entered all of the required details. <br />" ."Please go back and try again.<br /><br />" ."<a href='movies.php'>Go Back</a>"; exit; } @$db = new mysqli('localhost', 'root', '********', 'movie_info'); if (mysqli_connect_errno()) { echo "Error: Could not connect to database. Please try again later."; exit; } $query = "INSERT INTO movies VALUES (NULL, '".$title."', '".$year."', '".$genre."', '".$subgenre."', '".$director."', '".$actor1."', '".$actor2."', '".$actor3."', '".$discs."', '".$season."', '".$comments."')"; $result = $db->query($query); if ($result) { echo $db->affected_rows." has been inserted into the database."; //input_form(); } else { echo "An error has occurred. The item was not added."; //for testing echo "<br />Result: ".$result; echo "<br />".$title; echo "<br />".$year; echo "<br />".$genre; echo "<br />".$subgenre; echo "<br />".$director; echo "<br />".$actor1; echo "<br />".$actor2; echo "<br />".$actor3; echo "<br />".$discs; echo "<br />".$season; echo "<br />".$comments; //input_form(); } $db->close(); footer(); ?> This all will return all variable values (except $result), so it seems like $result is empty. Any help in understanding this would be greatly appreciated, Thanks!
  7. Hello, first off, I don't have a lot of programming experience. I am working off a YouTube tutorial... I am working with a simple PHP/MYSQL shopping cart that only supports one category and a Paypal checkout/add to cart button. My index.php page successfully shows the items that are in the database with the products() function. I have another function that shows the carts contents, cart(). That successfully displays the carts contents, if available. What I am trying to do is create another function cart_qty() to break apart the contents of cart() to see how many items there are. I would like to display, "You have 1 item" or "...2 items", ect. Any thoughts or helpful direction would be awesome! index.php <?php require 'cart.php'; ?> <!DOCTYPE html> <head> </head> <body> <div class="container"><!-- start container --> <div class="sixteen columns"> <h1 class="remove-bottom" style="margin-top: 40px">Test Shpping Cart </h1> <hr /> </div> <div id="products" class="two-thirds column"> <h1>Products In Our Store</h1> <?php echo products(); ?> </div> <div id="shoppingcart" class="one-third column"> <h3>Your Cart</h3> <?php echo cart(); ?> <br> <br> <br> <?php echo cart_qty(); ?> </div> </div><!-- end container --> </body> </html> cart.php <?php // Start the session session_start(); //session_destroy(); //error_reporting(0); $page = 'index.php'; mysql_connect('localhost', 'root', '') or die(mysql_error()); mysql_select_db('cart') or die(mysql_error()); // add item to cart if (isset($_GET['add'])) { $quantity = mysql_query('SELECT id, quantity FROM tblProducts WHERE id=' . mysql_real_escape_string((int)$_GET['add'])); //prevents SQL injections while($quantity_row = mysql_fetch_assoc($quantity)) { if($quantity_row['quantity'] != $_SESSION['cart_' . (int)$_GET['add']]) { $_SESSION['cart_' . (int)$_GET['add']] += '1'; } } header('Location: ' . $page); } // remove one item from cart if (isset($_GET['remove'])) { $_SESSION['cart_' . (int)$_GET['remove']] --; header('Location: ' . $page); } // delete item item from cart if (isset($_GET['delete'])) { $_SESSION['cart_' . (int)$_GET['delete']] = '0'; header('Location: ' . $page); } // display list of products function products() { $get = mysql_query('SELECT id, name, description, price, shipping FROM tblProducts WHERE quantity > 0 ORDER BY id ASC'); if (mysql_num_rows($get) ==0) { echo 'There are no products to display!'; } else { while($get_row = mysql_fetch_assoc($get)) { echo '<p>' . $get_row['name'] . '<br>' . $get_row['description'] . '<br>' . number_format($get_row['price'], 2) . '<br>' . $get_row['shipping'] . '<br><a href="cart.php?add=' . $get_row['id'] . '">Add</a></p>'; } } } //generate inputs required by PayPal function paypal_items() { $num = 0; foreach($_SESSION as $name => $value) { if($value != 0) { if(substr($name, 0, 5) == 'cart_') { $id = substr($name, 5, strlen($name)-5); $get = mysql_query('SELECT id, name, price, shipping FROM tblProducts WHERE id=' . mysql_real_escape_string((int)$id)); //prevents SQL injections while($get_row = mysql_fetch_assoc($get)) { $num++; echo '<input type="hidden" name="item_number_' . $num . '" value="' . $id . '">'; echo '<input type="hidden" name="item_name_' . $num . '" value="' . $get_row['name'] . '">'; echo '<input type="hidden" name="amount_' . $num . '" value="' . $get_row['price'] . '">'; echo '<input type="hidden" name="shipping_' . $num . '" value="' . $get_row['shipping'] . '">'; echo '<input type="hidden" name="shipping2_' . $num . '" value="' . $get_row['shipping'] . '">'; echo '<input type="hidden" name="quantity_' . $num . '" value="' . $value . '">'; } } } } } //display how many items are in the cart function cart() { foreach($_SESSION as $name => $value) { if($value>0) { if(substr($name, 0, 5) == 'cart_') { //get exact number after "'cart_'$id" $id = substr($name, 5, (strlen($name)-5)); //echo $id; $get = mysql_query('SELECT id, name, price FROM tblProducts WHERE id=' . mysql_real_escape_string((int)$id)); //prevents SQL injections while($get_row = mysql_fetch_assoc($get)) { $sub = $get_row['price'] * $value; echo $get_row['name'] . ' x ' . $value . ' @ $' . number_format($get_row['price'], 2) . ' = $' . number_format($sub, 2) . '<a href="cart.php?remove=' . $id .'">-</a> <a href="cart.php?add=' . $id .'">+</a> <a href="cart.php?delete=' . $id .'">delete</a><br>'; } } $total += number_format($sub, 2); } } if ($total == 0) { echo "Your cart is empty."; } else { echo 'Total: $' . number_format($total, 2) . ''; ?> <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="someone@yahoo.com"> <?php paypal_items(); ?> <input type="hidden" name="currency_code" value="USD"> <input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHosted"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> <?php } } function cart_qty() { ///how many items are in cart } ?>
  8. Hello. I've recently started learning PHP, and this has been irking me since: <?php $myTextbox = $_POST['myTextbox']; if(isset($myTextbox)&&!empty($myTextbox)){ echo 'You Typed: '.$myTextbox; } ?> <html> <head> <title>My 39 Site!</title> </head> <body> <form name = 'myForm' action = 'my39file.php' method = 'post'> <input type = 'text' name = 'myTextbox' value = '<?php echo $myTextbox; ?>'/> <input type = 'submit' name = 'submit'/></br></br> </form> </body> </html> It's a simple code I wrote. It has no errors, and it works just fine. The problem is that I don't understand WHY it works. I've been told numerously that the compiler reads code from top the bottom, but I'm failing to see how the rule applies in this case. For instance, at the beginning of the code, I declared the variable $myTextbox and set it equal to the value of the textbox I created in HTML below. This boggles me. The textbox is created AFTER I declare the variable, so how does the computer know what form element I'm talking about? I'm probably just omitting something. Could anybody enlighten me? Thanks.
  9. I'm very new to MySQL and trying to learn the basics. My question is this: I've created a simple database containing details of items owed to various patients by the pharmacy. I have made a search feature so that the staff can search quickly. In the search results, each patient's name is hyperlinked. When the hyperlink is clicked, I want it to go to a page where it displays all data from that row in the database table related to that patient. I have done this with an OwingID auto-incrementing variable in the table. I have the page set up where the data will display and can make it display any record I choose with this command: $displayowing = mysql_query("SELECT Date, FirstName, LastName, Item, Quantity FROM tOwings WHERE OwingID=1"); but I have to change the OwingID in the code myself from the server side. How do I make the links from the search results do this for me? Thanks...
  10. Hello. I designed a system a bit back and kinda cobbled it together. I was wondering if anyone could tell me of any security implications with the following setup: Usernames & passwords are stored on disk as a php array. A user enters their username and password into a form. On submit, the page include()s the username file & the checks to see if their username exists is the array. If it does, it checks that the password matches. If it does, a session variable key is assigned (username), with the username as the variable. As the user navigates the site, the session variables are maintained (session_start()), ensuring that a valid user is logged in. Is the above system relatively secure? Yes, it would be better over ssl and yes it would be vulnerable if a user managed to get read access to the files in the directory in which the usernames.php file is stored but it's on a hosting service which I believe to be secure and the uploader system ensures that uploads are stored in a separate directory with valid file extensions (.jpg etc). Thanks in advance for any advice. Toz
×
×
  • 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.