/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Posting equations to database after using post?

Greetings. I am looking for a code that can take the input of a number in a input box then after clicking on submit php takes that input calculates it with a already predefined equation then show output of answer and update both the input box and output into a database. I am very new still at all this I do understand just cant figure how to write it. If you would like to see a website that is similar to what I am looking for go to [URL=”http://<u>http://www.coinflation.com/coins/silver_coin_calculator.html</u>”][U][url]http://www.coinflation.com/coins/silver_coin_calculator.html[/url][/U][/URL]. this site is the closet that i can find that is close to what im looking for after you enter say 2 in the box for quantity then click on submit you are redirected to another page showing how much the 2 coins are worth however instead of going to another page would like to refresh same page with the answer as well as putting the quantity and answer into a database. Please help post the code or email it to me. or even point me to a page with the code.

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmMar 22.2014 — What good is it for someone here to write your code if you can't do anything on your own? What will you do with the code?

Better you should attempt to write Something and learn a bit and then ask for help with that.
Copy linkTweet thisAlerts:
@Error404Mar 22.2014 — In words, once the user clicks submit after entering their value, your submit.php page (or whatever you name it) will first have to do verification on the input. If the input is not valid, it will return the user to the input page with a message of why it wasn't valid. If the input is valid, then it calculates. PHP will write to the database, although the functions it uses will depend on the type of database you're using (i.e. MySQL, Oracle, MSSQL, etc...). Depending how your site is set up and what you exactly want, it will either use AJAX for asychronous loading, or use PHP or JavaScript to re-direct back to the input page, at which point, the calculated value will be displayed somewhere.

I'm not going to simply provide code for you since you'll be back at the same problem you're at now if you want to put in a new feature or change how it functions. If you show some of your code, then no problem, you'll get help with it.
Copy linkTweet thisAlerts:
@adistrolaauthorMar 30.2014 — ok so i what is i was trying at was for an example to playwith have basic understanding of code. the following is what i was able to come up with however it is not displaying or updating database. as you can see i even have script error and there is nothing i am lost

<?php

// Script Error Reporting

error_reporting(E_ALL);

ini_set('display_errors', '1');

?>

<?php

$int15="";

// Parse the form data and add inventory item to the system

if (isset($_POST['int1'])) {

$uid = $user_id;
$int1 = mysql_real_escape_string($_POST['int1']);
$int2 = mysql_real_escape_string($_POST['int2']);
$int3 = mysql_real_escape_string($_POST['int3']);
$int4 = mysql_real_escape_string($_POST['int4']);
$int5 = mysql_real_escape_string($_POST['int5']);
$int6 = mysql_real_escape_string($_POST['int6']);
$int7 = mysql_real_escape_string($_POST['int7']);
$int8 = mysql_real_escape_string($_POST['int8']);
$int9 = mysql_real_escape_string($_POST['int9']);
$int10 = mysql_real_escape_string($_POST['int10']);
$int11 = mysql_real_escape_string($_POST['int11']);
$int12 = mysql_real_escape_string($_POST['int12']);
$int13 = mysql_real_escape_string($_POST['int13']);
$int14 = mysql_real_escape_string($_POST['int14']);
$int15 = mysql_real_escape_string($_POST['int15']);
$int16 = mysql_real_escape_string($_POST['int16']);
$pr1 = $data['value']*0.0321507466*26.73 *0.9;
$pr2 = $data['value']*0.0321507466*26.73 *0.9;
$pr3 = $data['value']*0.0321507466*24.59 *0.4;
$pr4 = $data['value']*0.0321507466*12.5*0.9;
$pr5 = $data['value']*0.0321507466*12.5*0.9;
$pr6 = $data['value']*0.0321507466*12.5*0.9;
$pr7 =$data['value']*0.0321507466*12.5*0.9;
$pr8 = $data['value']*0.0321507466*11.5*0.4;
$pr9 = $data['value']*0.0321507466*6.25*0.9;
$pr10 = $data['value']*0.0321507466*6.25*0.9;
$pr11 = $data['value']*0.0321507466*6.25*0.9;
$pr12 = $data['value']*0.0321507466*2.5*0.9;
$pr13 = $data['value']*0.0321507466*2.5*0.9;
$pr14 = $data['value']*0.0321507466*2.5*0.9;
$pr15 = $data['value']*0.0321507466 * 5*0.35;
$pr16 = $data['value']*0.0321507466*31.1034768*.999;


// See if that product name is an identical match to another product in the system
$sql = mysql_query("UPDATE asilver SET int1='$int1', int2='$int2', int3='$int3', int4='$int4', int5='$int5', int6='$int6', int7='$int7', int8='$int8', int9='$int9', int1='$int10', int1='$int11', int1='$int12', int13='$int13', int14='$int14', int15='$int15', int16='$int16', pr1='$pr1', pr2='$pr2', pr3='$pr3', pr4='$pr4', pr5='$pr5', pr6='$pr6', pr7='$pr7', pr7='$pr7', pr8='$pr8', pr9='$pr9', pr10='$pr10', pr11='$pr11', pr12='$pr12', pr13='$pr13', pr14='$pr14',pr15='$pr15',pr16='$pr16',WHERE id='1'");

header("location: profle.php");
exit();

}

?>

<?php

// Gather this product's full information for inserting automatically into the edit form below on page

if (isset($_GET['id'])) {

$sql = mysql_query("SELECT int15 FROM asilver WHERE id='1' LIMIT 1");

$productCount = mysql_num_rows($sql); // count the output amount

if ($productCount > 0) {

while($row = mysql_fetch_array($sql)){

$int1 = $row["int1"];
$int2 = $row["int2"];
$int3 = $row["int3"];
$int4 = $row["int4"];
$int5 = $row["int5"];
$int6 = $row["int6"];
$int7 = $row["int7"];
$int8 = $row["int8"];
$int9 = $row["int9"];
$int10 = $row["int10"];
$int11 = $row["int11"];
$int12 = $row["int12"];
$int13 = $row["int13"];
$int14 = $row["int14"];
$int15 = $row["int15"];
$int16 = $row["int16"];

}
} else {
echo "Sorry nothing matches that request.";
exit();
}

}

}


}

else

{

exit();

}

?>
×

Success!

Help @adistrola spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...