Jump to content

Search the Community

Showing results for tags 'idkhow'.

  • 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 1 result

  1. Hi, I've question regards to the topic title above for, "how to get/post myorder page code to payment page??" which didn't retrieve any data from myorder page or do I need a database for myorder page?. As myorder page uses GET function to collect information from product page that using mysqli SELECT function to get data from the database. Also "how to get/post the Total from the myorder page to payment page??". Below are the following code: - myorder.php page <?php session_start(); include 'db2.php'; if ( !empty($_SESSION["firstname"])) { } else { $_SESSION["firstname"]=null; } ?> <?php session_start(); if(isset($_POST["add_to_cart"])) { if(isset($_SESSION["shopping_cart"])) { $item_array_id = array_column($_SESSION["shopping_cart"], "item_id"); if(!in_array($_GET["id"], $item_array_id)) { $count = count($_SESSION["shopping_cart"]); $item_array = array( 'item_id' => $_GET["id"], 'item_name' => $_POST["hidden_vname"], 'item_price' => $_POST["hidden_vprice"], 'item_quantity' => $_POST["quantity"] ); $_SESSION["shopping_cart"][$count] = $item_array; } else { echo '<script>alert("Item Already Added")</script>'; echo '<script>window.location="myorder.php"</script>'; } } else { $item_array = array( 'item_id' => $_GET["id"], 'item_name' => $_POST["hidden_vname"], 'item_price' => $_POST["hidden_vprice"], 'item_quantity' => $_POST["quantity"] ); $_SESSION["shopping_cart"][0] = $item_array; } } if(isset($_GET["action"])) { if($_GET["action"] == "delete") { foreach($_SESSION["shopping_cart"] as $keys => $values) { if($values["item_id"] == $_GET["id"]) { unset($_SESSION["shopping_cart"][$keys]); echo '<script>alert("Item Removed")</script>'; echo '<script>window.location="myorder.php"</script>'; } } } } ?> <div class="panel"> <div class="panel-heading clearfix"> <h4 class="panel-title pull-left" style="padding-top: 7.5px;">Your Order Summary</h4> </div><!-- end panel-heading --> <div class="table-responsive"> <?php if (null==$_SESSION["firstname"]) { echo "You got to <a href='signin.php'>Sign In </a>to see Your Order summary"; exit(); } else { $sql = "Select * from register where firstname = "."'".$_SESSION["firstname"]."'"; $result = mysqli_query($con, $sql); $userinfo = mysqli_fetch_assoc($result); echo '<h5>'; echo $userinfo["firstname"]." ".$userinfo["lastname"]; echo '<br>'; echo $userinfo["address"]; echo '<br>'; echo $userinfo["country"]." ".$userinfo["zipcode"]; echo '</h5>'; } ?> <br /> <table class="table table-bordered"> <tr> <th width="40%">Item Name</th> <th width="10%">Quantity</th> <th width="20%">Price</th> <th width="15%">Total</th> <th width="5%">Action</th> </tr> <?php if(!empty($_SESSION["shopping_cart"])) { $total = 0; foreach($_SESSION["shopping_cart"] as $keys => $values) { ?> <tr> <td><?php echo $values["item_name"]; ?></td> <td><?php echo $values["item_quantity"]; ?></td> <td>$ <?php echo $values["item_price"]; ?></td> <td>$ <?php echo number_format($values["item_quantity"] * $values["item_price"], 2); ?></td> <td><a href="myorder.php?action=delete&id=<?php echo $values["item_id"]; ?>"><span class="text-danger">Remove</span></a></td> </tr> <?php $total = $total + ($values["item_quantity"] * $values["item_price"]); } ?> <tr> <td colspan="3" align="right">Total</td> <td align="right">$ <?php echo number_format($total, 2); ?></td> <td></td> </tr> <?php } ?> </table> </div> <form method="post"> <a href="index.php" class="btn btn-default">Continue Browsing</a> <a href="checkout.php" class="btn btn-default">Check Out</a></form> </div> - payment.php page <?php session_start(); if ( !empty($_SESSION["firstname"])) { } else { $_SESSION["firstname"]=null; } ?> <?php if (null==$_SESSION["firstname"]) { echo "You got to <a href='signin.php'>Sign In </a>to see Your Checkout summary"; exit(); } else { } ?> <?php // define variables and set to empty values $firstnameErr = $lastnameErr = $addressErr = $countryErr = $zipcodeErr = $emailErr = $creditcardnoErr = $expireMMErr = $expireYYErr = $creditcardexpiryErr = ""; $firstname = $lastname = $address = $country = $zipcode = $email = $creditcardno = $expireMM = $expireYY = $creditcardexpiry= ""; $haserror = false; global $con; if (null==$_SESSION["firstname"]) { echo "Sign in <a href='signin.php'>Sign in</a> first before making payment"; exit(); } else { } if ($_SERVER["REQUEST_METHOD"] == "Post") { if (empty($_POST["firstname"])) { $firstnameErr = "Firstname is required"; } else { $firstname = test_input($_POST["firstname"]); } if (empty($_POST["lastname"])) { $lastnameErr = "Lastname is required"; } else { $lastname = test_input($_POST["lastname"]); } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); } if (empty($_POST["address"])) { $addressErr = "Address is required"; } else { $address = test_input($_POST["address"]); } if (empty($_POST["country"])) { $countryErr = "Country is required"; } else { $country = test_input($_POST["country"]); } if (empty($_POST["zipcode"])) { $zipcodeErr = "Zipcode is required"; } else { $zipcode = test_input($_POST["zipcode"]); } if (empty($_POST["creditcardno"])) { $creditcardnoErr = "Credit Card number is required"; $haserror = true; } else { $creditcardno = test_input($_POST["creditcardno"],$con); // Check if Creditcard only contains numbers if (!preg_match("/^[0-9]{15,16}$/",$creditcardno)) { $creditcardnoErr = "Only numbers allowed and minimum 15 digits"; $haserror = true; } } if (empty($_POST["expireMM"])) { $expireMMErr = "Expiry Month is required"; $haserror = true; } else { $expireMM = test_input($_POST["expireMM"],$con); } if (empty($_POST["expireYY"])) { $expireYYErr = "Expiry Year is required"; $haserror = true; } else { $expireYY = test_input($_POST["expireYY"],$con); } $creditcardexpiry = $expireMM.$expireYY; // Post to Database if no error if (!$haserror) { $sql = "INSERT INTO usercheckout (firstname, lastname, address, country, zipcode, email, creditcardno,creditcardexpiry,amount) VALUES (". "'".$firstname."'" . ", " . "'".$lastname."'" . ", " . "'".$address."'" . ", " . "'".$country."'" . ", " . "'".$zipcode."'" . ", " . "'".$email."'" . ", " . "'".$creditcardno."'" . ", " . "'".$creditcardexpiry."'" . ",". $_SESSION['total'].")"; if(mysqli_query($con, $sql)){ $sql0="SELECT MAX(paymentID) as paymentIDVal FROM usercheckout"; $result0 = mysqli_query($connection, $sql0); $pay = mysqli_fetch_assoc($result0); if (mysqli_query($connection, $sql0)){ $_SESSION['payid'] = $pay['paymentIDVal']; } $sql1 = "Select a.*, b.vname FROM shopping_cart a INNER JOIN video_products b ON a.vid=b.vid where checkout = 0"; $result1 = mysqli_query($con, $sql1); // Send out email for confirmed orders $subject = "Cherry Online Orders Confirmation"; $body = "<h2>Receipt Number: " . $_SESSION['payid'] . "</h2><br><br>"; $body .= "<table border='1'>"; $body .="<tr>"; $body .="<th>Product</th>"; $body .="<th>Unit Price</th>"; $body .="<th>Quantity</th>"; $body .="<th>Subtotal</th>"; $body .="</tr>"; while($row = mysqli_fetch_assoc($result1)){ $body .="<tr>"; $body .="<td>" . $row['vname'] . "</td>"; $body .="<td>" . $row['scprice'] . "</td>"; $body .="<td>" . $row['scquantity'] . "</td>"; $body .="<td>" . $row['scprice']*$row['scquantity'] . "</td>"; $body .="</tr>"; } $body .="</table>"; $headers = "From: StayONFLIX < stayonflix1234@gmail.com > \r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=utf-8\r\n"; mail($email,$subject,$body,$headers); // Set Checkout flag to 1 to signify item checked out $sql2 = "UPDATE shopping_cart SET Checkout = '1', paymentid =".$_SESSION['payid']." WHERE checkout = 0"; if(mysqli_query($con, $sql2)){ mysqli_close($con); header("Location: index.php"); } } // exit(); } } function test_input($data,$connection) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); $data = mysqli_real_escape_string($connection, $data); return $data; } ?> <div class="row"> <div class="col-md-6 col-sm-6 col-xs-6"> <div class="panel panel-default"> <div class="panel-heading">Payment Address</div> <div class="panel-body"> <p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> First Name: <input type="text" name="firstname" value="<?php echo $firstname;?>"> <span class="error">* <?php echo $firstnameErr;?></span> <br><br> Last Name: <input type="text" name="lastname" value="<?php echo $lastname;?>"> <span class="error">* <?php echo $lastnameErr;?></span> <br><br> E-mail: <input type="text" name="email" value="<?php echo $email;?>"> <span class="error">* <?php echo $emailErr;?></span> <br><br> Address: <input type="text" name="address" value="<?php echo $address;?>"> <span class="error">* <?php echo $addressErr;?></span> <br><br> Country: <input type="text" name="country" value="<?php echo $country;?>"> <span class="error">* <?php echo $countryErr;?></span> <br><br> Zipcode: <input type="text" name="zipcode" value="<?php echo $zipcode;?>"> <span class="error">* <?php echo $zipcodeErr;?></span> <br><br> Credit Card Number: <input type="text" name="creditcardno" value="<?php echo $creditcardno;?>" size="16" maxlength="16"> <span class="error">* <?php echo $creditcardnoErr;?></span> <br><br> Credit Card Expiry: <select name='expireMM'> <option value=''>Month</option> <option value='01'>January</option> <option value='02'>February</option> <option value='03'>March</option> <option value='04'>April</option> <option value='05'>May</option> <option value='06'>June</option> <option value='07'>July</option> <option value='08'>August</option> <option value='09'>September</option> <option value='10'>October</option> <option value='11'>November</option> <option value='12'>December</option> </select> <?php echo "<select name='expireYY'>"; echo "<option value=''>Year</option>"; for($i=0;$i<=10;$i++){ $expireYY=date('Y',strtotime("last day of +$i year")); echo "<option name='$expireYY'>$expireYY</option>"; } echo "</select>"; ?> <span class="error">* <?php echo $expireMMErr;?>&nbsp<?php echo $expireYYErr;?></span> <br><br> Amount: $<?php echo $_SESSION['total'];?> <br><br> <input type="submit" name="submit" value="Submit"> </form> </div> </div> </div> <div class="col-md-6 col-sm-6 col-xs-6"> <div class="panel panel-success"> <div class="panel-heading"> Review Order</div> <div class="panel-body"> <div class="row"> <div class="col-md-4 col-sm-4"> <span style="font-size:14px;"></span> </div> <div class="col-md-4 col-sm-4"> <span style="font-size:14px;">Item Name</span><br> <span style="color:rgba(99, 95, 95, 0.86);">Quantity: 1</span> </div> <div class="col-md-3 col-sm-3"> <span class="pull-right" style="font-weight:bold;font-size:20px;">$15.00</span> </div> </div> <hr> <div class="row"> <div class="col-md-6 col-sm-6"> <span style="font-weight:bold;font-size:20px;">Total Price</span> </div> <div class="col-md-5 col-sm-5"> <span class="pull-right" style="font-weight:bold;font-size:20px;">$15.00</span> </div> </div> </div> </div> </div> </div> Thanks for helping Appreciate alot, if someone could help.
×
×
  • 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.