PHP - Beginner Help: Poker Hole Card Function?
Hello,
I'm a beginner programmer, and for my first "php-script" im trying to deal myself two holecards. It's easy to get dealt the first card, but when the second card arrives I have to remove the first card from the array. How to do that? Or I could do like i have tried he if ($y != $x) { echo $y; }. Problem is when holecard number one = holecard number two it wont echo anything. So i need to say if holecard one = holecard two { do a new random }. But how do i do that? <?php function poker() { $cards = array("Ah", "Ac", "Ad", "As", "2h", "2c", "2d", "2s", "3h", "3c", "3d", "3s", "4h", "4c", "4d", "4s", "5h", "5c", "5d", "5s", "6h", "6c", "6d", "6s", "7h", "7c", "7d", "7s", "8h", "8c", "8d", "8s", "9h", "9c", "9d", "9s", "Th", "Tc", "Td", "Ts", "Jh", "Jc", "Jd", "Js", "Qh", "Qc", "Qd", "Qs", "Kh", "Kc", "Kd", "Ks"); $x = $cards[rand(0,51)]; echo "$x "; $y = $cards[rand(0,51)]; if ($y != $x) { echo $y; } } echo poker() . "<br>"; ?> Thanks! Similar TutorialsHey, i have made a silly little tester game just to see if i could, its he http://www.zephni.com/test/pairs its for some guy who is attending college and he was given the assignment to make a game of pairs using PHP to sort the cards and lay them down, and javascript to handle the actual game. Anyway at the moment, my game sorts out the cards as if they are values from 1 to 52, and picks randomly 18 cards from them. During the game, the cards have to be excatly the same, as in: if(card_picked1 == card_picked2){ win pair } that means that both cards would have to be the same number AND suit. But in pairs you have to pick the same number but obviously in a different suit. Any way I have been trying some diff code to pick 18 cards from the pack. It picks 9, and then doubles them up but +'s 13 to the card so it is the same number card. Here is the code Code: [Select] <?php $i = 1; $total_cards = 18; #Sorting out cards $card_sort = range(1,52); while($i <= ($total_cards/2)){ $pick_card = $card_sort[rand(1,52)]; if($pick_card !== null){ $cards[] = $pick_card; } unset($card_sort[$pick_card]); $i = $i+1; } foreach($cards as $card){ echo($card."<br/>"); } ?> I would of thought that when you unset the number from $card_sort that was picked it would'nt choose it again if($pick_card !== null) but it still chooses the same card twice sometimes. I know I really havent explained this well, but i did my best for 9am... I'd like to make myself a poker software that plays itself on all sites. What I don't know is how to get the variables names that I need. I need the cards variables name and the buttons name. Any suggestion how I do it? Or if I could read the from the screen somehow. Thanks Hello, Is it even feasible to create a multiplayer online poker or bingo site with PHP and AJAX? What type of architecture and programming languages are normally used for apps like that? I have an old db class that I created a while ago, and might switch to PDO. I just don't want to recode the whole site. The class was working really well to protect my db but they (spammers) have found a way around all my security and are posting links to porn, pills and russian. What I have is in the db class, there is a query function. Every query is sent to this function where it is sanitized and checks a table of blocked ips. I belive they are somehow bipassing this and going directly to the data base, becasue I am getting attacks from the same IP that should be blocked. The function looks something like this: Code: [Select] function query($sql) { if ($this->checkIp($_SERVER['REMOTE_ADDR'])) { $sql = $this->sanitize($sql); $result = mysql_query($sql); return $result; } else { die("<h1>You are banned for abuse!</h1>"); } } Does anybody have any suggestions? I have a web site that sells products. I have just added a table (mysql) that keeps track of searches. So when a user comes to the site from a search engine the search term(s) they used to find my site are stored along with their IP as an identifier and the landing page populates with products accordingly. Also when a user uses the local search feature it updates to add the new search term(s) to the table. The page displays the search box with whatever the last search term(s) were so at a later time all someone has to do is click search to repeat it. OK, so far so good. Then I got on my iphone to test it out and when the page loaded the search terms used on my laptop were there. Duh... same IP from the network. So this is my security hole that I am trying to plug. My site doesn't set any cookies and I was trying to keep it that way, but I am thinking I may have to stray from that in order to do this. I don't suppose there is a way in php to get a users mac address is there? I was hoping that someone could offer me some tidbits of wisdom to guide me in these dark times For those not knowing about this, is a new security hole found in all linux/unix based operating systems that should be patched.
http://arstechnica.c...with-nix-in-it/
Hey guys, I am new to php and I have a project to do that includes creating a payroll system.What i am trying to get done is a clock in and clock out time card using php.This is what I have so far but when I run it, the date and time is incorrect can someone please help me Hi, I want to know something on credit card processing. I do not have any problem here, but want to know how ca shopping website is processed! For example, a website is selling shoes online, where people will use either VISA or any credit card to buy, then the shoes will be delivered to the person's place. I want to know, how these credit cards are stored, I mean do these information are stored in the database, the website administrator will take the credit number etc...to get the money from the bank? My website needs to collect credit card information WITHOUT 3rd party!
I asked godaddy what i is i need for that and they told me if i get a merchandising account with my bank and call them to tell them what i want to do they will send me a script and i use that script on my site.
Does anyone have experience with this?
my server is PCI compliant
I'm looking at creating a web interface for cusotmers to enter credit card information. What is the best approach for this? Keeping in mind security of data... Maybe this last point is more a question for web server administrators, but thought I'd ask anyway. Hello, I'm trying to use a rest-based card clearence service, but I don't know how to pass the information through the URL without using the form action attribute. I need to have a URL looking like this: index.php?p=checkout?service=cardAuth&msg_id=3864&num_md5=e2740266aab85558996a9a87fc561c0e&amount=24.99¤cy=GBP&api_key=739a720ade31ad2a14b30aa7b3a6b20e But at the moment, I have a URL looking like this: index.php?cardAuth=&title=Mr&fname=Alderton&sname=Arkie&ctype=mastercard&cnumber=5105105105105100&smonth=01&syear=07&fmonth=01&fyear=10&checkout=Check+Out There's a few more problems; - I can't get the card number to md5 - I don't know how to retreive a variable used in another file, which counts up the total amount due Here's my PHP: Code: [Select] <h2>Please enter your details</h2> <h3>All fields required</h3> <div id="checkout"> <?php if (isset($_GET['checkout'])){ $title = $_GET['title']; $fname = $_GET['fname']; $sname = $_GET['sname']; $ctype = $_GET['ctype']; $cnumber = md5($_GET['cnumber']); $syear = $_GET['smonth'] . $_GET['syear']; $fyear = $_GET['fmonth'] . $_GET['fyear']; $service = $_GET['cardAuth']; $amount = $_REQUEST[$total]; $msg = rand(1000,9999); $api = 'd41d8cd98f00b204e9800998ecf8427e'; } ?> <form method="get" action="index.php?p=checkout?<?php.'service='.$service.'msg_id='.$msg.'num_md5='.$cnumber.'amount='.$amount.'currency=GBP'.'api_key='.$api.?>"> <table> <tr> <td><input type="hidden" name="cardAuth" value="<?php if (!empty($service)) echo $service; ?>" /></td> </tr> <tr> <td> Title: </td> <td> <select name="title" value="<?php if (!empty($title)) echo $title; ?>" > <option></option> <option>Mr</option> <option>Sir</option> <option>Ms</option> <option>Miss</option> <option>Mrs</option> </select> </td> </tr> <tr> <td> First Name: </td> <td> <input type="text" name="fname" value="<?php if (!empty($fname)) echo $fname; ?>"/> </td> </tr> <tr> <td> Surname: </td> <td> <input type="text" name="sname" value="<?php if (!empty($sname)) echo $sname; ?>"/> </td> </tr> <tr> <td> </td> </tr> <tr> <td> Card Type: </td> <td> <select name="ctype" value="<?php if (!empty($ctype)) echo $ctype; ?>"> <option>mastercard</option> <option>visa</option> <option>amex</option> <option>solo</option> <option>maestro</option> <option>jcb</option> <option>diners</option> </select> </td> </tr> <tr> <td> Card Number: </td> <td> <input type="text" name="cnumber" value="<?php if (!empty($cnumber)) echo $cnumber; ?>"/> </td> </tr> <tr> <td> Valid From: </td> <td> <select name="smonth" value="<?php if (!empty($smonth)) echo $smonth; ?>"> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> </select> <select name="syear" value="<?php if (!empty($syear)) echo $syear; ?>"> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> </select> </td> </tr> <tr> <td> Expires End: </td> <td> <select name="fmonth" value="<?php if (!empty($fmonth)) echo $fmonth; ?>"> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> </select> <select name="fyear" value="<?php if (!empty($fyear)) echo $fyear; ?>"> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> </select> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> <td> <input type="submit" name="checkout" value="Check Out"/> </td> </tr> </table> </form> </div> I have two sites on two different servers server1: has the purchase page where it asks for credit card numbers etc. server2: has the CGI files to send payment data directly into the payment processor. I cannot put the CGI files on server1 due to security restrictions, etc. My question is: How can I securely transmit the credit card data from server1 to server2? Thanks! This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=315057.0 Hi there.... I am facing problem regarding credit card transaction ....an error i am keep on getting "Security header is not valid"....i searched for that but all are saying that its because of using "wrong credentials"...but i have gone through all my docs....i think i am using the right one......anyone there to help me out please....i really need it to get done.........thanxx..... Hello! I have sim card, how can we integrate it with server and use web interface to send sms and other requests, all handled via PHP?? Just an idea will be appreciated. thanks watsmyname I need to display Credit card number with only last 4 digits visible.The remaining numbers should display as ** eg: If the credit card number is 2222 1111 3333 4444 its should display as **** **** **** 4444 in a textbox Can anybody provide me a solution Not sure if this is in the right forum (if not can a mod move it please).... Im creating a site that is based on a subscription basis. Therefore i need to allow the user to input their card details for me to store to allow payments every month (and also for them to update when needed). How do you recommend storing card details in the database, im guessing its not secure just to store them as plain text? Opinions needed Hi there, I'm new to PHP about 5month (previously i don't have any programming background), i study the basic PHP through online. i found a tutorial from : http://www.phpwebcommerce.com/ , and there is some error in this tutorial + i need customize this tutorial for my site. I'm here to ask , is the tutorial suitable beginner like me ? is the tutorial consider for advanced used ? i able to solve some error in this tutorial but it take too long. Can give a solution ? should i give up this tutorial on my site ? or just continue find solution ? but i'm already spent almost 2month in this tutorial. so far, i left shipping cost cant find solution...(but i have try do it for 2weeks) Thank you. Hi, I'm trying to set up a mysql database on my laptop, XP, and connect to a test database using php. I've created the database called 'testdb' with user account 'test' and password 'password. The code I'm using to try and connect to the test datase is the following; $dbconnect=mssql_connect("localhost", "test", "password"); But when I open the page in a web browser, I am getting the following error; Fatal error: Call to undefined function mssql_connect() in <file_location> I'm hoping I'm doing something simple here, but, I've looked up forums and this seems to be the code to use to connect. Anyone who could help would be greatly appreciated. Thanks. |