PHP - Not Submiting The Info
Hi all, Ive latly coded a option for my website which allowes users to send money. Ive finished coding it but when I press the submit button the money dont get sent to the other user it just puts it in the url bar.
Example: http://********.com/newbank.php?touser=Test&sendmoney=1000000000&sendmoney=Send+Money! <?php session_start(); include ("includes/db_connect.php"); include ("includes/functions.php"); logincheck(); $username = $_SESSION['username']; // Fetch users stuff.. $fetch_u = mysql_query("SELECT * FROM users WHERE username='$username'") or die (mysql_error()); $fetch_users = mysql_fetch_object($fetch_u); // Fetch bank stuff.. $fetch_b = mysql_query("SELECT * FROM bank") or die (mysql_error()); $fetch_bank = mysql_fetch_object($fetch_b); // User sending money.. if ($_POST['sendmoney']){ $send_money = strip_tags($_POST['ammount']); $to_user = strip_tags($_POST['touser']); if (!$to_user){ echo ("You must enter a username."); }elseif ($to_user){ $user_real = mysql_num_rows(mysql_query("SELECT * FROM users WHERE username = '$to_user'")) or die (mysql_error()); if ($user_real == 0){ echo ("No such user!"); }elseif ($user_real != 0){ if ($send_money > "0"){ if ($send_money == 0 || !$send_money || ereg('[^0-9]',$send_money)){ echo ("You carnt send that type of money"); }elseif ($send_amount != 0 || $send_amount || !ereg('[^0-9]',$send_amount)){ if ($send_money > $fetch->money){ echo ("You havent got that much money"); }elseif ($send_money <= $fetch->money){ // Try sending money to yourself if (strtolower($to_user) == strtolower($username)){ echo ("You cannot send money to yourself"); }elseif (strtolower($to_user) != strtolower($username)){ $to_person = mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$to_user'")); $otherusercash = $send_money; $otheruser = $to_user->money + $otherusercash; mysql_query("UPDATE users SET money = money-$send_money WHERE username='$username'"); mysql_query("UPDATE users SET money = '$otheruser' WHERE username='$to_person'"); $time = gmdate('Y-m-d h:i:s'); mysql_query("INSERT INTO `transfers` ( `id` , `to` , `from` , `amount` , `date` ) VALUES ('', '$to_person', '$username', '$send_amount', '$time')") or die (mysql_error()); echo "Money Sent!"; echo "<meta http-equiv=\"refresh\" content=\"0;URL=newbank.php\">"; } } } } } } } ?> <html> <head> <link rel="stylesheet" href="includes/in.css" type="text/css"> <style type="text/css"> .infobg { font-family: Arial; font-weight:normal; font-size:12px; border-top: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; background: URL(textbg1.png); font-weight:300; } .button { font-size: 12px; background:url(button.png); vertical-align: middle; border-top: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; color: #FFFFCC; height:23px; font-weight:300; border-radius: 10px; padding-bottom:2px; } </style> <title>Running-Mafia || Send Money</title> </head> <body> <form action='' name='form1'> <table width='50%' border='1' bordercolor='#000000' align='center' bgcolor='#808080' cellpadding='0' cellspacing='0' style='border-collapse: collapse'> <tr> <td colspan='2' background='header.jpg' align='center'>Send Money</td> </tr> <tr> <td> Username: </td> <td> <input type='text' name='touser' class='infobg' id='touser'> </td> </tr> <tr> <td> Ammout: </td> <td> <input name="sendmoney" class='infobg' type="text" id="send_money"> </td> </tr> <tr> <td> </td> <td> <input class="button" name="sendmoney" type="submit" id="sendmoney" value="Send Money!"> </td> </tr> </table> </form> </body> </html> Anyone see why its not sending the money? Thanks. Similar TutorialsHi im currently learning php and mysql and as a test (or a lesson) i thaught id do a timesheet site which adds the time and date and so on to the datatbase. Now im at the stage where i want to actually view the times for a particular date... The problem im getting is that with the date picker which is a simple dropdown menu for the days/month/year but when i submit the form to the view.php file the result i get is 'Submit Query' which is the value of the button... Can someone give me a few pointers on what im doing wrong!!! Thank you Chris Hey im agen stuck on code i get You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 but i think i have all correct if i submit i get values but that dont add in database Code: [Select] <?php //Values if(isset($_POST['Submit'])) { $request = preg_replace("/[^0-9a-zA-Z]/","",$_SERVER['REQUEST_URI']); $ip = preg_replace("/[^0-9a-zA-Z]/","",$_SERVER['REMOTE_ADDR']); $referer = preg_replace("/[^0-9a-zA-Z]/","",$_SERVER['HTTP_REFERER']); $agent = preg_replace("/[^0-9a-zA-Z]/","",$_SERVER['HTTP_USER_AGENT']); //Open connection include('connectx.php'); //Test is there connection available $query=("Select * from Error where date='NOW()'"); $result= mysql_query($query); $num=mysql_num_rows($result); //Add data $query=("INSERT INTO Error (id,request,ip,referer,date,agent) VALUES ('NULL','$request','$ip','$referer',NOW(),'$agent'"); if (@mysql_query($query)) { echo('<p>Error code has succesfuly send</p>'); } else { echo ("Error was in submiting code").mysql_error(); } mysql_close(); } ?>any help will become welcome Currently what I'm trying to do is to create a blogging software through PHP (for myself) and when trying to change the amount of posts viewable on the edit/delete page, the form, which auto-submits if JavaScript is enabled, should deliver the following result:
"/?page=EditPost&limit=6"
This is obviously depending on what value is chosen, it can be anywhere from 5 to 10. But what it is actually returning is "?limit=6".
This is the PHP script for the function:
public function EchoLimitSelector() { $limit = isset($_GET['limit']) ? $_GET['limit'] : NULL; echo "<div class='tright'>"; echo "<form action='?page=EditPost&limit=".$limit."' method='GET'>"; echo "<span>Posts per page: </span>"; echo "<select name='limit' style='font-size: 16px; width: 50px;' onchange='this.form.submit();'>"; for($x = 5; $x <= 10; $x++) { echo "<option value=".$x. " "; //Setting default selected value if($limit) { if($limit == $x) { echo "selected"; } } else { if($x == 5) { echo "selected"; } } echo ">".$x."</option>"; } echo "</select>"; echo "<noscript><input type='submit' value='Go' style='height: 26px; padding: 0; margin-top: -7px;'/></noscript>"; echo "</form>"; echo "</div>"; }I'm hoping that it's just a simple fix. Thanks. Ubuntu PHP Mysql So I got this form validator script online and I applied the validator part of it to my own form. My form requires a NAME and a SERIAL to be inputted and the SERIAL must be all numbers. I tested the validator by leaving NAME blank in my form and SERIAL all letters. The dispalyed resutls show the correct error messages: "Name : Please fill in a name for this computer." and "Serial : Please fill in a serial number for this computer." But the entry is still submitted with the errors and all. Here is my validator script. It begins by calling the script I got online which is from this website: http://www.html-form-guide.com/php-form/php-form-validation.html <?PHP require_once "formvalidator.php"; $validator = new FormValidator(); $validator->addValidation("Name","req","Please fill in a name for this computer."): $validator->addValidation("Serial","req","Please fill in a serial number for this computer"); $validator->addValidation("Serial","num","Serial number must be only numeric values"); if($validator->ValidateForm()) { echo "<h2>Validation Success!</h2>"; } else { echo "<B>Validation Errors:</B>"; $error_hash = $validator->GetErrors(); foreach($error_hash as $inpname => $inp_err) { echo "<p>$inpname : $inp_err</p>\n"; } } } ?> As title says i need to block user for 30 minutes after he enter invalid data 3 times in a row. I know i need to enter ip and time in database, but how to stop form to be submited.
i have this code for count failed attempts, he increment value in session every time submit is pressed
// postavi ili povecaj broj u sessiji ako je Login button aktiviran if (empty($_SESSION['failed_login'])) { $_SESSION['failed_login'] = 1; } elseif (isset($_POST['login'])) { $_SESSION['failed_login']++; } // if login fail 3 times if ($_SESSION['failed_login'] > 3) { $error[] = 'U failed to login 3 times ' . $_SESSION['failed_login']; }This is whole login.php <?php // protect page from direct access if (!defined('AUTH')) { die('You are not authorized to see this page !'); } if ($general->is_logged() === true) { header('Location: index.php'); exit(); } $last_login_date = time(); $ip = $general->get_ip(); // postavi ili povecaj broj u sessiji ako je Login button aktiviran if (empty($_SESSION['failed_login'])) { $_SESSION['failed_login'] = 1; } elseif (isset($_POST['login'])) { $_SESSION['failed_login']++; } // if login fail 3 times if ($_SESSION['failed_login'] > 3) { $error[] = 'U failed to login 3 times ' . $_SESSION['failed_login']; } // login form if (isset($_POST['login'])) { $username = trim($_POST['username']); $password = trim($general->safepass($_POST['password'])); // if user entered username and password if (empty($username) || empty($password)) { $error[] = 'Please enter username and password'; } else { // login query $login = $users->login($username, $password); // cookie login if (isset($_POST['stay_logged'])) { // check if username and password is valid if ($login) { $user_id = $login['id']; // expire time for cookie 1 month $expire = time()+60*60*24*30; // make random code for token $rand = hash('sha512', mt_rand()); // set cookies setcookie('token', $rand, $expire); setcookie('username', $login['username'], $expire); setcookie('id', $login['id'], $expire); // update user last_login, ip, token code $update_login_data = $users->update_cookie_login($last_login_date, $ip, $rand, $user_id); // redirect user to index.php and exit script header('Location: index.php'); exit(); } else { // if username or password is not valid $error[] = 'Invalid username or password'; } } // session login else { // check if username and password is valid if ($login) { // make sessions with user_id and username $_SESSION['id'] = $login['id']; $_SESSION['username'] = $login['username']; $user_id = (int)$_SESSION['id']; // update user last_login, ip $update_login = $users->update_user_ip_login($last_login_date, $ip, $user_id); // redirect user to index.php and exit script header('Location: index.php'); exit(); } else { // if username or password is not valid $error[] = 'Invalid username or password'; } } } } ?> <h3>Log in</h3> <?php if (!empty($error)) { echo '<div class="big-error-msg"><ul style="margin:0 0 0 20px;">'; foreach ($error as $error) { echo '<li>'.$error. '</li>'; } echo '</ul></div>'; } ?> <form action="" method="POST" class="login-form"> <input type="text" name="username" placeholder="Username" required> <input type="password" name="password" placeholder="Password" required><br><br> <input type="checkbox" name="stay_logged"><label style="padding:0 0 0 10px;">Remember me ?</label><br> <input type="submit" name="login" value="Log in" class="small-button"> <label> <p><a href="index.php?page=forgotten_pass" title="Forgotten password ?">Forgotten password ?</a></p> <p>Don't have an account ? <a href="index.php?page=register" title="Register">Register</a></p> </label> </form> Very simple question. I have a table with courses and a table with students registered for those courses. I have a page where I can change the course name. What I want to do is, when changing the course name in the course table, I want all students in the students table who are already registered for that course to have that course name updated as well in the student table. I'm currently using a field cid to update the courses in the course table however, the student table doesn't have a cid field rather a cname ( course name) which I want to use to update the fields in the student table. Is it possible to use Code: [Select] <a href=\"editcourse.php?cid=" for more than one field of info? i.e transfer the cid + cname and so you can use $_GET[cid]"; and $_GET[cname]"; ? Something like this maybe ( dont know how the code will go) "editcourse.php?cid=&cname=" ? Do I have the right idea for how to go about this? Hey guys, It's been awhile since I've coded in PHP and I can not for the life of me remember how to do this. Say I have http://www.example.com/search.php?name=joe&size=small What the PHP code to grab the ?name=joe&size=small part? thanks Hi Experts, How can I check whether I have FSOCKOPEN support from phpinfo() page? Thanks, In my script, users login with their Username & Password. However, I'd like to be able to echo the email address used on their account.
I've tried adding the email to the session I'm not having much luck... Here's a piece of the login code(untouched); $username = $_POST['name']; $passwd = $_POST['passwd']; $query = "SELECT name,passwd FROM users WHERE CONCAT('0x', hex(passwd)) = '{$salt}'"; $result = mysql_query($query); $login_ok = false; if(mysql_num_rows($result) > 0) { $login_ok = true; } if($login_ok) { $row = mysql_fetch_array($result, MYSQL_NUM); $_SESSION['user'] = $row;I've also tried messing around with this piece below in a few different ways but still nothing. <?php echo htmlentities($_SESSION['user']['email'], ENT_QUOTES, 'UTF-8'); ?>Any help is greatly appreciated.. I am parsing an rss feed from my flickr photostream using this:-
<?php $url = "http://api.flickr.com/services/feeds/photos_public.gne?id=49466419@N05&lang=en-us&format=rss_200"; $rss = simplexml_load_file($url); if($rss) { echo '<h1>'.$rss->channel->title.'</h1>'; echo '<li>'.$rss->channel->pubDate.'</li>'; $items = $rss->channel->item; foreach($items as $item) { $title = $item->title; $link = $item->link; $published_on = $item->pubDate; $description = $item->description; echo '<h3><a href="'.$link.'">'.$title.'</a></h3>'; echo '<span>('.$published_on.')</span>'; echo '<p>'.$description.'</p>'; } } ?>which gives me this as the description for each image:- public 'description' => string ' <p><a href="http://www.flickr.com/people/alfthomas/">Alf Thomas</a> posted a photo:</p> <p><a href="http://www.flickr.com/photos/alfthomas/14064465890/" title="harlaw_12"> <img src="http://farm6.staticflickr.com/5077/14064465890_83c02ecec6_m.jpg" width="240" height="110" alt="harlaw_12" /> </a> </p> <p>A view of Harlaw Reservoir.</p>' (length=338)What I actually want is the photo (linked back) without the "Alf Thomas posted a photo" bit, does anyone have any idea how I would go about cloning that bit out? Edited by foucquet, 31 May 2014 - 08:14 AM. This is a multiplication test for students to take and when they finish they click the score button. after they click the score button it tells them what their score is, with the opportunity to take it again. What I am trying to do is make this able to keep the recent score and just post the next score. Right now my app just gives the first score and then when I take the test again it just refreshes and gives the new score. I want it to play the new score under the old score. I can't seem to figure out how to do this. If someone could help point me in the right direction. Would appreciate the help. Here is my code for my app.... Code: [Select] <?php require_once('database.php'); define ('ROWS', 3); define ('COLS', 3); define ('MAX_NUMBER', 12); date_default_timezone_set('America/New_York'); if (isset($_POST['btn_score'])) { $result_name= $_POST['result_name']; $correct = 0; //print_r ($_POST); $time1 = $_POST['ts']; $time1_object = new DateTime($time1); $now = new DateTime(); $time_span = $now->diff($time1_object); $minutes = $time_span->format('%i'); $seconds = $time_span->format('%s'); $seconds+= $minutes * 60; echo "It took $seconds seconds to complete the test<hr />"; foreach ($_POST as $problem => $answer) { if ($problem <> "btn_score" && $problem <> "ts" && $problem <> "result_name") { //echo "$problem -- $answer <br />"; $problem = explode('_', $problem); $num1 = $problem[2]; $num2 = $problem[3]; $right = $num1 * $num2; if ($answer != $right) { echo "$num1 * $num2 = $answer , The right answer is $right<br />"; }else { $correct = $correct + 1; } } } $result_score= 0; $result_score= ($correct / 9) * 100; echo "your score is <br/>$result_score<br/>"; } $sql = "INSERT INTO results (result_name, result_score, result_date_time) VALUES ('$result_name','$result_score', NOW());"; ?> <h1>Multiplication Test</h1> <form name="lab5" method="post" action="lab5b.php"> <?php $now = new DateTime(); //echo $now->format('Y-m-d H:i:s'); echo "<input type='hidden' name='ts' value='" . $now->format('Y-m-d H:i:s') . "'>"; ?> <table border="1" cellspacing="5" cellpadding="5"> <?php $no_of_problems = 0; for ($row=0; $row<ROWS; $row++) { echo "<tr>"; for ($col=0; $col<COLS; $col++) { $num1 = mt_rand(1,MAX_NUMBER); $num2 = mt_rand(1,MAX_NUMBER); echo "<td>$num1 * $num2 </td>"; echo "<td><input type='text' size='2' name=${no_of_problems}_mult_${num1}_${num2}></td>"; $no_of_problems++; } echo "</tr>"; } $colspan = 2 * COLS; echo "<tr><td colspan=$colspan align='right'><input type='submit' value='Score' name='btn_score'></td></tr>"; ?> When I get a hit on my site I like to see where they came from and if they came from a search engine what keywords they used. So here is the refer info: http://www.google.com/search?q=dog+training&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a I guess I need to split everything into an array or something. Has anyone done this? Any Ideas? Thank you! hello guys i heard there is a way that you can make something like a database on a text editor and when ever u want to change the info you just open a text editor and change the information How is this called? where can i find a tutorial? any tips? thanks you very much let's say I have 100,000 users on my forum i want to cache there PROFILE INFO (About me) in .php files which is easy/etc but would that be more space than 100k rows in a db table, or 100k .php files? just wondering, prob a stupid question but atm I cache some lottery info and some other stuff, but that's only 1 .php it would be dumb to cache info and have 100k .php's for each user ID right? or maybe story it all in 1 .php? would be a HUGE Filesize? rather just keep the data in MYSQL right? Hi Ive currently developed a script that connects via an API to send a message, and tested it with one user and it works perfectly. But now im bit stuck to send it to multiple users. All my visitors unique IDs are being stored into a file called unique.csv all in 1 column under each other. But what im currently trying to do is to recall the info from the csv and make a contact list to broadcast the message to.
The csv file looks like:
27823116700
m59317461002 For some odd reason, my MySQL array is not returning any data. I echo'd the query and it is correct, I looked at the database and that row is in there, but when I print_r the array, nothing. Here is the code. $infoquery = "SELECT * FROM '$endotype' WHERE ID = '$typeid' ORDER BY ID DESC LIMIT 1"; $info = mysql_query($infoquery); echo $infoquery; $infoout = mysql_fetch_array($info); print_r($infoout); Its a very simple query and its driving me nuts. hello, i am transferring the post number from a forum page, to a non-forum page via url variables.. how do i stop someone editing the url variable and viewing the posts concerned? i thought i could possibly use cookies/or a kind of auto-post form.. please help if you can.. just what to google would be appreciated ok im back quicker than i thought.... i got my drop box sorted and i got it reloading the page. so it all works correctly. but how do i get the page to display information regarding the film i have selected in the drop box.? i have no code for this at the mo. also i would like the drop box to display the selected item at top of box when it refreshes code for drop box: Code: [Select] <FORM> <?php $result = mysql_query( "SELECT * FROM movie_info ORDER BY title ASC ") ; echo "<select name= Film onChange='submit()' >film name</option>"; while ($nt=mysql_fetch_array($result)){ ?> <?php echo "<option value='$nt[id]'>$nt[title] </option>"; } ?> </select> </FORM> any help would be great Hi guys I need some info Am doing an upload page for pictures, that crops images to two different sizes which works fine with small images. However some larger images it doesn't work (locally it works but not on the my server provider). I can upload the file (3481 * 2346 at 300 dpi) no problem but it actually never executes the imagecreatefromjpeg($myUploadedFile). Is there any issues with large file. I've been doing some recherches but can't seem to find any answer. The obvious idea is to have people upload photos without asking them to resize them. Thanks |