php - Submitting values to database from form -


i have billing page fetches data cart.

i having problem submitting these values database. how correct php submit database correctly?

for example, have transactions table in database, , want payment details go there, can later fetched , outputted in admin section receipt of order.

i cannot name, address, email, phone submit correctly. comes 0 in database, how fix this?

how can use ajax when button clicked show loading bar/page , success message?

i error:

notice: undefined index: command in f:\xamppnew\htdocs\web\billing.php on line 5 

code:

    <?php include "storescripts/connect_to_mysql.php";  session_start();   if($_request['command']=='update'){         $name=$_request['name'];         $email=$_request['email'];         $address=$_request['address'];         $phone=$_request['phone'];         $item_id = $_session['item_id'];         $quantityorder = $each_item['quantity'] = $_session['quantity1'];         $carttotal = $_session['carttotal'];      // add product database     $sql = mysqli_query($link,"insert transactions values('','$item_id','$quantityorder','$carttotal','$name','$address','$email','$phone')");          die('thank you! order has been placed!');     } ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="style/style.css" type="text/css" media="screen" /> <title>billing info</title> <script language="javascript">     function validate(){         var f=document.form1;         if(f.name.value==''){             alert('your name required');             f.name.focus();             return false;         }         f.command.value='update';         f.submit();     } </script> </head>    <body> <div align="center" id="mainwrapper">   <?php include_once("template_header.php");?>   <div id="pagecontent">     <div style="margin:24px; text-align:left;">      <br /> <form name="form1" onsubmit="return validate()">     <input type="hidden" name="command" />     <div align="center">         <h1 align="center">billing info</h1>         <table border="0" cellpadding="2px">              <tr><td>product id:</td><td><?php echo $item_id = $_session['item_id'];?></td></tr>             <tr><td>total quantity:</td><td><?php echo $each_item['quantity'] = $_session['quantity1']; ?></td></tr>             <tr><td>order total:</td><td>£<?php echo $carttotal = $_session['carttotal'];?></td></tr>             <tr><td>your name:</td><td><input type="text" name="name" /></td></tr>             <tr><td>address:</td><td><input type="text" name="address" /></td></tr>             <tr><td>email:</td><td><input type="text" name="email" /></td></tr>             <tr><td>phone:</td><td><input type="text" name="phone" /></td></tr>             <tr><td>&nbsp;</td><td><input type="submit" value="place order" /></td></tr>         </table>     </div>     </div>         <?php include_once("template_footer.php");?>  </form> </body> </html> 

did use mysqli connect ? if yes, change mysql_query mysqli_query

and need add 'name' attribute submit button , this

if(isset($_post['submit'])){.... 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -