Jump to content

Search the Community

Showing results for tags 'php'.

  • 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

  1. I have a form with a table with columns and many rows. The form uses Post and submits to an insert.php I am looking for an example of how I can insert the table info into a mysql table. I know I should use a while loop but unsure how to step through the form info. Can someone suggest or provide and example that I can follow, or a tutorial somewhere? Thanks
  2. Hi, I have an application where during registration a user will choose when they want to be reminded of an event. For instance the event lets say will start on 2017-02-02 and i scheduled it on 2016-12-30 and i want to be reminded everyday from 10days to the event date(2017-02-02). How do i go about it? I need idea as to know how to go about it. I dont know if cron will be good. Thanks
  3. update super set `name` = REPLACE(`name`, ',' , ' ') I have the following code that removes the comma in a MySQL database column & replaces it with a blank. In the above example, the database is named super & the column is named name. This code works great but currently I'm running the script each day & changing it to also remove periods, question marks, etc. Is there a way I can edit the above code that will not only find & replace the , with a blank space, but edit it so it will find the periods, commas, question mark, exclamation mark, etc all in one run? Please help as I am currently editing the above code to numerous other things to find & replace daily. Thank
  4. Hi I have a question about API keys and security. I am building a mobile app (learning) and will be using a PHP/MySQL JSON Rest API (designed myself) and I am new to APIs in general so some best practices would be appreciated if you have any? My real question is to do with securing these APIs. For example I was thinking of using user name and password that the user logs into the application with to be send over HTTPS for each request to validate the user is authorised and authenticated. However I have read that I should also be using API keys, so how would I integrate this in? Would each user have their own unique API key or would each system that uses this API have a unique key? If its each user that has their own key would I send all three pieces of data with the request (API Key, username and password). Any advice would be great. Thanks
  5. I have seen a lot of demos or sort of the same questions with the Select All option. But what I want is to just have a drop down that will allow me to select All option and not showing the entire Select box. Individual Select option works but not when I tried to use ALL as an option. Here is my sample HTML: <select name="status" id="status" style="width: 224px;"> <option value="" selected="selected">Please select...</option> <option value="All">All</option> <option value="Option1">Option1</option> <option value="Option2">Option2</option> <option value="Option3">Option3</option> <option value="Option4">Option4</option> </select> From the code above I would want to filter the result using the All option. So this is the page is where I filter and show the results in a table, <script> $(document).ready(function(){ $("#results").show(); }); </script> <script type="text/javascript"> $(document).ready(function(){ $("#RetrieveList").on('click',function() { var status = $('#status').val(); var date = $('#Date').val(); var date1 = $('#Date1').val(); $.post('retrieve_status.php',{status:status, date:date, date1:date1}, function(data){ $("#results").html(data); }); return false; }); }); </script> <form id="form2" name="form2" method="post" action=""> <table width="941" border="0" align="center"> <tr> <th width="935" colspan="9" scope="col">Status: <select name="status" id="status" style="width: 224px;"> <option value="" selected="selected">Please select...</option> <option value="All">All</option> <option value="Option1">Option1</option> <option value="Option2">Option2</option> <option value="Option3">Option3</option> <option value="Option4">Option4</option> </select> Start Date:<input type="text" name="Date" id="Date" size="8"/> End Date:<input type="text" name="Date1" id="Date1" size="8"/> <input name="action" type="submit" id="RetrieveList" value="Retrieve List" /> </th> </tr> </table> </form> <div id="results"> </div> And this is how I fetch the data, <?php require 'include/DB_Open.php'; $status = $_POST['status']; $date = $_POST['date']; $date1 = $_POST['date1']; if ($_POST['status'] == 'ALL') { $sql_status = '1'; } else { $sql_status = "status = '".mysql_real_escape_string($_POST['status'])."'"; } $sql="SELECT column1, column2, status FROM tracker WHERE status = '" . $sql_status . "' AND scheduled_start_date BETWEEN '" . $date . "' AND '" . $date1 . "' ORDER BY scheduled_start_date"; $myData = mysql_query($sql); //to count if there are any results $numrow = mysql_num_rows($myData); if($numrow == 0) { echo "No results found."; } else { echo "CRQ Count: $numrow"; } { echo "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'> <tr> <th align='center'><strong>Column1</strong></th> <th align='center'><strong>Column2</strong></th> <th align='center'><strong>Status</strong></th> </tr>"; while($info = mysql_fetch_array($myData)) { echo "<form action='retrieve_status.php' method='post'>"; echo"<tr>"; echo "<td align='center'>" . $info['column1'] . "<input type=hidden name=column1 value=" . $info['column1'] . " </td>"; echo "<td align='center'>" . $info['column2'] . "<input type=hidden name=column2 value=" . $info['column2'] . " </td>"; echo "<td align='center'>" . $info['status'] . "<input type=hidden name=status value=" . $info['status'] . " </td>"; echo "</tr>"; echo "</form>"; } } echo "</table>"; include 'include/DB_Close.php'; ?>
  6. Hi guys, How can i process the value of a search result. this is what i've tried so far: //searche result page if(isset($_POST['submit'])){ $_SESSION['from'] = $_POST['from']; $_SESSION['to'] = $_POST['to']; $sql = ("SELECT * FROM $tbl_name WHERE date_order BETWEEN '$_SESSION[from]' AND '$_SESSION[to]'"); //$stmt = $pdo->prepare("SELECT * FROM ca_processed"); $stmt=$pdo->query($sql); $stmt->execute(); $num_rows = $stmt->rowCount(); #print "<p>$num_rows Record(s) Found.</p>"; if($stmt->rowCount() < 1){ echo '<div class="alert alert-warning text-center">NO RECORD FOUND</div>'; }else{ print "<p>$num_rows Record(s) Found.</p>"; <form action="ReconcileAccounts" method="post"> <table width="100%" class='table-responsive table-condensed table-striped'> <tr> <td bgcolor="#444444"><font color='#fff'></font></td> <td bgcolor="#444444"><font color='#fff'><strong>#</strong></font></td> <td bgcolor="#444444"><font color='#fff'>Trans Ref</font></td> <td bgcolor="#444444"><font color='#fff'>Service Provider</font></td> <td bgcolor="#444444"><font color='#fff'>Service Type</font></td> <td bgcolor="#444444"><font color='#fff'><strong>($) Amount</strong></font></td> <td bgcolor="#444444"><font color='#fff'><strong>Date Paid</strong></font></td> <td bgcolor="#444444"><font color='#fff'><strong>Reconcile Status</strong></font></td> </tr> <?php $i = 1; while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $trans_ref = $row['trans_ref']; $service_provider = $row['service_provider']; $service_type = $row['service_type']; $amount_paid = number_format($row['amount_paid'],2); $date_paid = $row['date_paid']; $reconcile_status = $row['reconcile_status']; if($reconcile_status == 0){ $reconcile_status = "<strong>NOT RECONCILED</strong>"; }elseif($reconcile_status == 1){ $reconcile_status = "<strong>RECONCILED</strong>"; } $reconcile_info = [ 'trans_ref' => $trans_ref, 'service_provider' => $service_provider, 'service_type' => $service_type, 'amount_paid' => $amount_paid, 'date_paid' => $date_paid, 'reconcile_status' => $reconcile_status ]; $_SESSION['reconcile_info'] = $reconcile_info; ?> <tr> <td align="center"><input name="check_list[]" type="checkbox" value="<?php echo $row['id']; ?>" ></td> <td><?php echo $i++; ?></td> <td><?php echo $trans_ref; ?></td> <td><?php echo $service_provider; ?></td> <td><?php echo $service_type; ?></td> <td><?php echo $amount_paid; ?></td> <td><?php echo $date_paid; ?></td> <td><?php echo $reconcile_status; ?></td> </tr> <?php } ?> </table> <input name="reconcile" type="submit" class="btn btn-primary btn-margin" id="reconciled" value="RECONCILE SELECTED"> </form> } } //ReconcileAccounts $tbl_name="xbp_paid_bills"; //your table name $tbl_name2="xbp_registration_info"; if(isset($_POST['reconcile'])){ if(!empty($_POST['check_list'])){ foreach($_POST['check_list'] as $selected){ $stmt = $pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING ); $stmt = $pdo->prepare("UPDATE xbp_paid_bills SET reconcile_status =1 WHERE trans_id='$selected'"); $stmt->execute(); $count = $stmt->rowCount(); } if($count){ echo "<div class='bg-success alert alert-success text-center'>RECORD(S) RECONCILED</div>"; $url = "ReconcileAccount"; echo '<meta http-equiv="refresh" content="3;URL=' . $url . '">'; }else{ echo "<div class='bg-warning alert alert-warning text-center'>A PROBLEM OCCURED WHILE RECONCILING RECORD</div>"; echo "<br>"; print_r($stmt->errorInfo()); } } } thanks
  7. Hello guys, I'm try to sum rows in a UNION but having a hard time about it $stmt = $pdo->prepare("SELECT due_date, SUM(amount_paid) FROM ( SELECT due_date, amount_paid FROM table1 union all SELECT due_date, amount_paid FROM table2 UNION ALL )x GROUP BY MONTH"); $stmt->execute(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo $row['x']; thanks
  8. Hi, I have a problem. I am doing one little job with php and html. In html i have textbox in which person id must be entered (11 numbers) I need to do with php that when all 11 numbers are entered, date of birth and gender need to be shown, For example: if id is : 39310121111 first number stands for mele/female (if 3 mele if 4 female) all next numbers are date of birth 1993 10 12 (last 4 numbers doesnt have meaning) Basicly question is. how to make syntax that entered id will be shown as gender and date of birth ? can't think of any ideas. new at php.
  9. I'm trying to save some json data to an mysql table through php but I do have some issues I'm just stuck into the loop and the validation doesn't go like I want to. These are some dummy data of the json Object [entiteteTeReja] => Array ( [cmimeReja] => Array ( [0] => Array ( [KODNIVELCMIMI] => N1 [KODARTIKULLI] => BOBLT0009 [KODNJESIA1] => cope [MONEDHAKOD] => LEK [DTFILLIMIT] => 2015-01-01T00:00:00.000Z [DTMBARIMIT] => 9999-12-31T00:00:00.000Z [CMIMI] => 3450 [CMIMI2] => 3450 [KODNJESIA2] => cope [DTMODIFIKIM] => 2015-05-11T16:42:45.046Z [IDSTATUSDOK] => 1 [BRUTONETONIVELCMIMI] => 1 [NIVELCMIMIBAZE] => [KOHEFILLIMI] => 1900-01-01T00:00:00.000Z [KOHEMBARIMI] => 1900-01-01T23:59:59.000Z ) . . . . [834] => Array ( [KODNIVELCMIMI] => N2 [KODARTIKULLI] => BOBLT0009 [KODNJESIA1] => cope [MONEDHAKOD] => LEK [DTFILLIMIT] => 2015-01-01T00:00:00.000Z [DTMBARIMIT] => 9999-12-31T00:00:00.000Z [CMIMI] => 3450 [CMIMI2] => 3450 [KODNJESIA2] => cope [DTMODIFIKIM] => 2015-05-12T16:58:24.746Z [IDSTATUSDOK] => 1 [BRUTONETONIVELCMIMI] => 1 [NIVELCMIMIBAZE] => [KOHEFILLIMI] => 1900-01-01T00:00:00.000Z [KOHEMBARIMI] => 1900-01-01T23:59:59.000Z ) . . . . [834] => Array ( [KODNIVELCMIMI] => N3 [KODARTIKULLI] => BOBLT0009 [KODNJESIA1] => cope [MONEDHAKOD] => LEK [DTFILLIMIT] => 2015-01-01T00:00:00.000Z [DTMBARIMIT] => 9999-12-31T00:00:00.000Z [CMIMI] => 3450 [CMIMI2] => 3450 [KODNJESIA2] => cope [DTMODIFIKIM] => 2015-05-12T16:58:24.746Z [IDSTATUSDOK] => 1 [BRUTONETONIVELCMIMI] => 1 [NIVELCMIMIBAZE] => [KOHEFILLIMI] => 1900-01-01T00:00:00.000Z [KOHEMBARIMI] => 1900-01-01T23:59:59.000Z ) lso this is the Php Script that I tried so far, foreach($obj['entiteteTeReja']['cmimeReja'] as $key => $x){ $query = "SELECT COUNT(*) AS nr FROM cmimedatatable WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; $result = $mysqli->query($query); if( nr == 1){ if($x['KODNIVELCMIMI'] == 'N1'){ $query = "UPDATE cmimedatatable SET C1 = ".$x['CMIMI']." WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; } else if($x['KODNIVELCMIMI'] == 'N2'){ $query = "UPDATE cmimedatatable SET C2 = ".$x['CMIMI']." WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; } else if($x['KODNIVELCMIMI'] == 'N3'){ $query = "UPDATE cmimedatatable SET C3 = ".$x['CMIMI']." WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; } else if($x['KODNIVELCMIMI'] == 'N4'){ $query = "UPDATE cmimedatatable SET C4 = ".$x['CMIMI']." WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; } else if($x['KODNIVELCMIMI'] == 'N5'){ $query = "UPDATE cmimedatatable SET C5 = ".$x['CMIMI']." WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; } else if($x['KODNIVELCMIMI'] == 'N6'){ $query = "UPDATE cmimedatatable SET C6 = ".$x['CMIMI']." WHERE KODARTIKULLI = '".$x['KODARTIKULLI']."' "; } } else if ( nr == 0){ if($x['KODNIVELCMIMI'] == 'N1'){ $query = "INSERT INTO cmimedatatable(KODARTIKULLI, C1,C2, C3, C4, C5, C6) VALUES('".$x['KODARTIKULLI']."',".$x['CMIMI'].",0,0,0,0,0)"; } else if($x['KODNIVELCMIMI'] == 'N2'){ $query = "INSERT INTO cmimedatatable(KODARTIKULLI, C1,C2, C3, C4, C5, C6) VALUES('".$x['KODARTIKULLI']."',0,".$x['CMIMI'].",0,0,0,0)"; } else if($x['KODNIVELCMIMI'] == 'N3'){ $query = "INSERT INTO cmimedatatable(KODARTIKULLI, C1,C2, C3, C4, C5, C6) VALUES('".$x['KODARTIKULLI']."',0,0,".$x['CMIMI'].",0,0,0)"; } else if($x['KODNIVELCMIMI'] == 'N4'){ $query = "INSERT INTO cmimedatatable(KODARTIKULLI, C1,C2, C3, C4, C5, C6) VALUES('".$x['KODARTIKULLI']."',0,0,0,".$x['CMIMI'].",0,0)"; } else if($x['KODNIVELCMIMI'] == 'N5'){ $query = "INSERT INTO cmimedatatable(KODARTIKULLI, C1,C2, C3, C4, C5, C6) VALUES('".$x['KODARTIKULLI']."',0,0,0,0,".$x['CMIMI'].",0)"; } else if($x['KODNIVELCMIMI'] == 'N6'){ $query = "INSERT INTO cmimedatatable(KODARTIKULLI, C1,C2, C3, C4, C5, C6) VALUES('".$x['KODARTIKULLI']."',0,0,0,0,0,".$x['CMIMI'].")"; } } $mysqli->query($query); } And this is how the data are saved in my table,
  10. My problem is that everytime when a user uploads photos through my app in openshift it gets lost.When i try to update the code through git,I couldn't find a solution on the net.So I came here for experts advice. i would also appreciate if anyone can point me to an article that does it for php app in openshift. The problem is simple my user uploaded files are stored in /user/{$_SESSION['id']} folder that is located in repo folder. through research i found that it should be stored in app-root/data folder. If so how can i store user uploaded photos directly there and access it for the user who wants to view it in browser directly like www.testing-pad4u.rhcloud.com/home.php?u={$_SESSION['name']}. i have no clue on how to do it please help me or point me in the right direction as i'm a total noob to Linux.
  11. I have 5 dropdowns on a tab of a website. I have a database table in MS SQL Server. The table has all the data of 5 dropdowns with one of the fieldNames called Region_Name, say the Region_Names are A, B, C, D, and E. I have written codes to display a table and enabled row editing for one of the RegionNames. Now, I am wondering if I could modify the same codes to display associated table with row editing enabled using different queries when a dropdown is clicked. That could reduce the code repetition and improve the performance. But I do not know how to achieve this. Could anyone please give me some hints? I am using PHP PDO to connect to the database.
  12. Trying to retrieve information from an API and display it in a table. <form action="dublinbus.php" method="get"> <h2>Current Dublin Bus Times.</h2> <b>Stop Number: </b><input type="number" name="stopid"></br></br> <input type="submit"> </form> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ <?php $stopID = $_GET['stopid']; $url = "https://data.dublinked.ie/cgi-bin/rtpi/realtimebusinformation?stopid=" . $_GET['stopid'] . "&format=json"; // Process the JSON and check for errors $json = file_get_contents($url); $array = json_decode($json,true); if ($stopID != $array["stopid"]) { // Get the values for $errorCode and $errorMessage $errorCode = $array["errorcode"]; $errorMessage = $array["errormessage"]; echo "Error: "; echo $errorCode; echo $errorMessage; } else { // Get the values $duetime = $array["duetime"]; $destination = $array["destination"]; $route = $array["route"]; echo " <table>"; echo " <th>Stop Number</th><th>Route</th><th>Due Time</th><th>Destination</th>"; echo " <tr><td>" . $stopID . "</td><td>" . $route . "</td><td>" . $duetime . "</td><td>" . $destination . "</td></tr>"; echo "</table>"; } ?>
  13. I need help getting the data from phpMyAdmin to display in a php table: <?php $con = mysqli_connect('localhost', 'root', 'root', 'music_database'); if(!$con) { die("Can not connect: " . mysqli_error($con)); } if(!mysqli_select_db($con, 'music_database')) { echo 'Database Not Selected!'; } $sql = "SELECT * FROM month1"; $query = mysqli_query($con, $sql); if (!$query) { // add this check. die('Invalid query: ' . mysqli_error($con)); } else{ echo "<table border=1> <tr> <th>Song Title</th> <th>Song Artist</th> <th>Song Album</th> <th>Year Released</th> <th>Month Played</th> <th>Day of the Week Played</th> <th>Date Played</th> <th>Time Played</th> </tr>"; while($record = mysqli_fetch_array($query)) { echo "<tr>"; echo "<td>" . $record['songtitle'] . "</td>"; echo "<td>" . $record['songartist'] . "</td>"; echo "<td>" . $record['songalbum'] . "</td>"; echo "<td>" . $record['yearreleased'] . "</td>"; echo "<td>" . $record['monthplayed'] . "</td>"; echo "<td>" . $record['dayplayed'] . "</td>"; echo "<td>" . $record['dateplayed'] . "</td>"; echo "<td>" . $record['timeplayed'] . "</td>"; echo "</tr>"; } echo "</table>"; } mysqli_close($con); ?> showrecords.php
  14. 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.
  15. Hi there, I have a page of products listed on a categories page, at the minute the mysql results are split into 3 columns, but when the page opens on a larger / high res screen there is a lot of space down the right hand side of the products. I was hoping someone might be able to help me so these move when necessary. I have pasted the categories page, if anything else is needed please let me know. Hope to hear from someone. thanks. MsKazza <?php session_start(); include('Connections/adlantic.php'); ?> <!doctype html> <html> <head> <style> /* Remove the navbar's default margin-bottom and rounded borders */ .pagination { background: #0066FF; border-radius: 15px; } .rest { font:Arial, Helvetica, sans-serif; color:#0066FF; float: left; padding: 8px 8px; text-decoration: none; border: 1px solid #ddd; margin: 0 4px; transition: background-color .3s; } .rest a { color:#0066FF; text-decoration:none; transition: background-color .3s; } /* Set height of the grid so .sidenav can be 100% (adjust as needed) */ .active { font:Arial, Helvetica, sans-serif; color:#ffffff; background:#0066FF; float: left; padding: 8px 8px; text-decoration: none; border: 1px solid #ddd; margin: 0 4px; } </style> <?php $recordID = $_GET["recordID"]; $result_category = mysqli_query($con, "SELECT products.*, categories.* FROM products INNER JOIN categories ON products.category=categories.id WHERE cat_name='$recordID' AND products.product_publish='1'"); $row_category = mysqli_fetch_assoc($result_category); $metatitle= $row_category['cat_name']; $metadesc=$row_category['cat_name']; $metakeywords=$row_category['cat_name'] . "business gifts, corporate gifts, promotional products, promotional items, promotional merchandise, promotional giveaways, advertising products, sales promotion, giveaways, exhibition, conference, environmentally friendly products, eco products, printed"; include('header.php'); ?> <meta http- equiv="content-type" content="text/html;charset=UTF-8"> <script src="js/lightbox-2.6.min.js"></script> <script type="text/javascript"> $(function() { //More Button $('.more').live("click",function() { var ID = $(this).attr("id"); if(ID) { $("#more"+ID).html('<img src="moreajax.gif" />'); $.ajax({ type: "POST", url: "ajax_more.php", data: "lastmsg="+ ID, cache: false, success: function(html){ $("ol#updates").append(html); $("#more"+ID).remove(); } }); } else { $(".morebox").html('The End'); } return false; }); }); </script> <link href="css/lightbox.css" rel="stylesheet" /> <br /> <div style="clear: both;"> <br /> <div class="content-area"> <div class="page-content"> <div class="product"> <div class="product-name">Categories</div> <div class="product-info" style="background:#E5E4E4; margins:auto;"> <br /> <table border=0 width="550px" align="center" cellpadding="5" cellspacing="5" bgcolor="#FFFFFF"><tr> <?php $result = mysqli_query($con, "SELECT * FROM sub_categories WHERE cat_name='$recordID' ORDER BY subcat_name ")or die($result. "<br/><br/>".mysql_error()); $count = 0; $max = 4; while($row = mysqli_fetch_assoc($result)) { if (['$result'] > 0){ $count++; echo '<td style="padding:5px;"><img src="eCommerceAssets/images/arrow.png"> <a href="sub_category.php?recordID='.$row['id'].'" class="topbar">'.$row['subcat_name'].'</a></td>'; if($count >= $max){ //reset counter $count = 0; //end and restart echo '</tr><tr>'; } } elseif ($result = 0) { echo 'There are no Subcategories available.'; } } ?> </tr></table> <?php $recordID = $_GET["recordID"]; // find out how many rows are in the table $query = mysqli_query($con, "SELECT COUNT(*) FROM products WHERE category='$recordID' AND product_publish='1'"); $r = mysqli_fetch_array($query); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 18; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db $query = "SELECT * FROM products INNER JOIN images ON products.product_code=images.product_code WHERE category=$recordID AND product_publish='1' ORDER BY product_id ASC LIMIT $offset, $rowsperpage"; $rs_result = mysqli_query($con, $query); $cat_name = $row_category['cat_name']; // always make sure you get a valid result!!! if($result == false) { die("Query failed: ".mysqli_error().PHP_EOL.$query); } echo "<br /><br />"; echo "<b>You are viewing page " . $currentpage . " of " . $totalpages . "</b><br />"; echo "We found " . $numrows . " products <br />"; ?> <?php if ($rs_result == NULL) { echo "There are no products to display in this category"; } else { ?> <br /><br /> <table align="center" border=0 width="550px" cellpadding="5" cellspacing="5"><tr> <?php $count1 = 0; $max1 = 3; while($row1 = mysqli_fetch_assoc($rs_result)) { $prod_name = $row1['product_name']; if(strlen($prod_name)>24){ $prod_name=substr($prod_name,0,24).' ...'; } if (['$rs_result'] > 0){ $count1++; echo '<td align="center" valign="top">'; echo '<table align="center" bgcolor="#ffffff" width="160"><tr><td height="5" align="center">'; echo '</td></tr><tr><td align="center">'; echo '<a href="product.php?name='; echo $row1['slug']; echo '" class="topbar">'; echo '<img src="eCommerceAssets/images/products/'; echo $row1['product_image_big1']; echo '" width="150" height="200">'; echo '</a>'; echo '</td></tr><tr><td align="center">'; echo '<strong><a href="product.php?name='; echo $row1['slug']; echo '" class="prod-name">'; echo $prod_name; echo '</a></strong><br />'; echo '<a href="product.php?name='; echo $row1['slug']; echo '" class="button">More Info</a><br />'; echo '</td></tr></table><br /><br />'; echo '</td>'; if($count1 >= $max1){ //reset counter $count1 = 0; //end and restart echo '</tr><tr>'; } } elseif ($rs_result = 0) { echo 'There are no products available.'; } } ?> </tr></table> <?php } // close while loop echo "<br />"; /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo "<span class='rest'> <a href='?recordID=$recordID&currentpage=1'><<</a> </span>"; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo "<span class='rest'> <a href='?recordID=$recordID&currentpage=$prevpage'><</a></span> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo "<span class='active'> <b>$x</b> </span>"; // if not current page... } else { // make it a link echo "<span class='rest'><a href='?recordID=$recordID&currentpage=$x'>$x</a> </span>"; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo "<span class='rest'> <a href='?recordID=$recordID&currentpage=$nextpage'>></a></span>"; // echo forward link for lastpage echo "<span class='rest'> <a href='?recordID=$recordID&currentpage=$totalpages'>>></a></span>"; } // end if /****** end build pagination links ******/ // close if ?> </div> </div> </div><!-- end of page-content --> <div class="left-side"> <?php include('menu.php'); ?> </div><!-- end of left side panel --> </div><!--end of content-area--> <br /> <div style="clear: both;"><br /> <?php include('footer.php'); ?> </div> <script src="js/cbpFWTabs.js"></script> <script> new CBPFWTabs( document.getElementById( 'tabs' ) ); </script> </body> </html>
  16. Hello, The below is the code i have i want to track down the ipaddress of the people who ever subscribed to my list. I am beginner in php kindly do the needful. Thanks a lot in advance. <!-- Subscribe form --> <form action="subscribe/NLprocess.php" method="post"> <h6 class=footer-widget-heading>Enter your email:</h6> <div class="input"> <input type="text" class="button" name="email" placeholder="Email address"> <input type="submit" class="button" id="submit" value="Subscribe"> </div> </form> <!-- End subscribe form --> The processing file NLprocess.php ---- $emailmanager = 'smallstamps@gmail.com'; // SECOND: // save this file, and close it. Thank you! error_reporting(0); $email = trim($_POST['email']); $Ok = ereg("^([a-zA-Z0-9_\.-]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", $email); if ($Ok) { mail($emailmanager,'Subscribe','','From: '.$email); if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$UNameFrm)) { ?> <script language = 'javascript'> alert('Thank you, Now you Subcribed to smallstamps.com Updates'); history.go(-1); </script> <? exit(); } } else { if(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",$UNameFrm)) { ?> <script language = 'javascript'> alert('Sorry, please provide a valid Email address.'); history.go(-1); </script> <? exit(); } } ?> Kindly let me know what i have to do to track the ip address.
  17. Hi Guys, I have a JET SQL query that i need to convert to MYSQL (Appologies too if this is posted in the wrong section.. i never know whether to go PHP or MYSQL!) Im not being lazy.. ive tried for hours but cannot get it to work, it has two depth inner join and a group by with a where (with 1 criteria)... If anyone can help id massively appreciate it and also explain how you got there... SELECT Count(tbl_Items.ItemID) AS CountOfItemID, tbl_LU_Collections.CollectionDesc FROM (tbl_Items LEFT JOIN tbl_LU_Categories ON tbl_Items.ItemCategory = tbl_LU_Categories.ItemCatID) LEFT JOIN tbl_LU_Collections ON tbl_LU_Categories.CollectionID = tbl_LU_Collections.CollectionID WHERE (((tbl_Items.RetailProduct)=-1)) GROUP BY tbl_LU_Collections.CollectionDesc;
  18. Hi All, how to display php table like attachment? it mean that, there is 2 members registered in November, but it have 0 member get approve. There is 3 members registered in December, and total have 5 members get approved (2 from November + 3 from December). Each Register and Approve have their individual dates. I get all my thing wrong as i can loop only by either Register date or Approved date. example. member1 ->Registered date : 21/11/2016 (Fall under November) ->Approved date : 2/12/2016 (Fall under December) member2 ->Register date : 23/11/2016 (Fall under November) ->Approved date: 3/12/2016 (Fall under December) Thanks in advance.
  19. Hello guys, i have implemebted facebook login for my website. However, tring to store the data into my local db seems to be a problem. I'll need a little assistance with the coding. Thanks in advance. BELOW IS THE ERROR MESSAGE I GET Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/xxxx/public_html/3rd_party/fbOAuth/functions.php on line 16 Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/xxxx/public_html/3rd_party/fbOAuth/functions.php on line 17 Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/xxxx/public_html/3rd_party/fbOAuth/functions.php on line 20 MY CODE <?php //require 'dbconfig.php'; $DBhost = "localhost"; $DBuser = "xxxx"; $DBpass = "xxxx"; $DBname = "xxxx"; $DBcon = new MySQLi($DBhost,$DBuser,$DBpass,$DBname); if ($DBcon->connect_errno) { die("ERROR : -> ".$DBcon->connect_error); } function checkuser($fbid,$fbfullname,$femail){ LINE 16: $check = mysqli_query("select from Users where Fuid='$fbid'"); LINE 17: $check = mysqli_num_rows($check); if (empty($check)) { // if new user . Insert a new record $query = "INSERT INTO Users (Fuid,Ffname,Femail) VALUES ('$fbid','$fbfullname','$femail')"; mysqli_query($query); } else { // If Returned user . update the user record $query = "UPDATE Users SET Ffname='$fbfullname', Femail='$femail' where Fbid='$fuid'"; LINE 20: mysqli_query($query); } }?> I'll be grateful for all the help i can get.
  20. Hello All, I'm a student currently enrolled in a PHP course, and our instructor has told us to create code that would accept a users birthday and then calculate how many days from today is their next birthday. The program returns a value, but the value is incorrect. I should never receive a value over 365 days. Example: Input: 04/11/1985 Today's Date is 11/9/2016 Output (should be): "You have 153 days until your next Birthday" Actual Output: "You have 212 days until your next Birthday" What did I do wrong? Thanks in advance for any assistance Michelle <?php $johnsBirthday = $_GET ['JohnBday']; $jakesBirthday = $_GET ['JakeBday']; $john_bday = new DateTime($_GET['JohnBday']); $jake_bday = new DateTime($_GET['JakeBday']); $today_date = new DateTime(); switch (true) { case ($john_bday < $today_date) : $today_date->setDate($john_bday->format('Y'), $today_date->format('m'), $today_date->format('d')); break; case ($today_date < $john_bday) : $john_bday->setDate($today_date->format('Y'), $john_bday->format('m'), $john_bday->format('d')); break; } switch (true) { case ($today_date < $jake_bday) : $jake_bday->setDate($today_date->format('Y'), $jake_bday->format('m'), $jake_bday->format('d')); break; case ($jake_bday < $today_date) : $jake_bday->setDate($today_date->format('Y'), $jake_bday->format('m'), $jake_bday->format('d')); break; } $john_interval = $john_bday->diff($today_date); $john_diff = $john_interval->format('%a'); echo "John you have $john_diff days until your next Birthday</br>"; $jake_interval = $jake_bday->diff($today_date); $jake_diff = $jake_interval->format('%a'); echo "Jake you have $jake_diff days until your next Birthday</br>"; if ($johnsBirthday < $jakesBirthday) { echo "John is older than Jake</br>"; } elseif ($johnsBirthday > $jakesBirthday) { echo "Jake is older than John</br>"; } else { echo "Jake and John are twins"; } ?>
  21. Hi folks, brand new here and hope that you can help me; I'm looking for very generic pagination for my page. I'll paste in some html and go from there: <div class="row paginate"> <div class="col-12"> <nav> <a href="index.php" class="active">01</a> <a href="index-02.php">02</a> <a href="index-03.php">03</a> <a href="index-04.php">04</a> <a href="index-05.php">05</a> </nav> </div> </div> What I'm looking for is php inside of the link to echo the .active class based on whether or not you're on the index-02.php page or index-03.php page etc... I'm not using any mysql for this so I hope it's possible. I also plan on putting that chunk of html in an include file so I don't have to manually keep adding new links to every page :/ The site it's going on is one of my own at http://www.harshclimate.com/photos if you wanna see the entire HTML Thanks, all!
  22. I have never used cURL before and have hit a roadblock in my learning. I am trying to make a HTTP GET request to my Wowza server which uses the Rest API to return JSON results. I have authentication set to none on the server at the moment until I can get the script working. I have tested the code below with an external website and it works but, when I try to use it with the URL from the server with the Rest API it just times out. I can make the request in a browser fine, just not from the code. What am I missing or not doing correctly? $ch = curl_init("http://IP_TO_SERVER:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/incomingstreams/ncopeland"); // such as http://example.com/example.xml curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, 0); $data = curl_exec($ch); curl_close($ch); print $data; The response should be this. { "serverName": "_defaultServer_", "sourceIp": "ncopeland", "isPTZEnabled": false, "applicationInstance": "_definst_", "name": "ncopeland", "isRecordingSet": false, "isStreamManagerStream": true, "isPublishedToVOD": false, "isConnected": true, "ptzPollingInterval": 2000 } -Thanks!
  23. Hello I've been trying to fix this problem for around 3 weeks; so what I want is to be able to send a picture and being able to display it in another page. It send it to the server, but still it doesn't show it. Here is my code: <?php require_once('../Connections/connection.php'); ?> <?php $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_post")) { $tiempocotejo= time(); $insertSQL = sprintf("INSERT INTO posts (titulo, categoria, tag, imagen, contenido, descripcion, estatus, plantilla,link, price, autor) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['titulo'], "text"), GetSQLValueString($_POST['categoria'], "text"), GetSQLValueString($_POST['tag'], "text"), GetSQLValueString($_POST['imagen'], "text"), GetSQLValueString($_POST['contenido'], "text"), GetSQLValueString($_POST['descripcion'], "text"), GetSQLValueString($_POST['estatus'], "int"), GetSQLValueString($_POST['plantilla'], "int"), GetSQLValueString($_POST['link'], "text"), GetSQLValueString($_POST['price'], "text"), GetSQLValueString($_SESSION['MM_Id'], "int")); mysql_select_db($database_connection, $connection); $Result1 = mysql_query($insertSQL, $connection) or die(mysql_error()); mysql_select_db($database_connection, $connection); $query_SacarIdPost = sprintf("SELECT posts.id FROM posts WHERE time=%s",$tiempocotejo,"int"); $SacarIdPost = mysql_query($query_SacarIdPost, $connection) or die(mysql_error()); $row_SacarIdPost = mysql_fetch_assoc($SacarIdPost); $totalRows_SacarIdPost = mysql_num_rows($SacarIdPost); mysql_free_result($SacarIdPost); $updateSQL = sprintf("UPDATE posts SET urlamigable= %s WHERE id=%s", GetSQLValueString(limpia_espacios($_POST['titulo'],$row_SacarIdPost['id']), "text"), GetSQLValueString($row_SacarIdPost['id'], "int")); mysql_select_db($database_connection, $connection); $Result1 = mysql_query($updateSQL, $connection) or die(mysql_error()); $insertGoTo = "publishedpost" . UrlAmigablesInvertida($row_SacarIdPost['id']).".php"; header(sprintf("Location: %s", $insertGoTo)); } ?> <style> #select{ padding-left:0px; } #select2{ padding-right:0px; } </style> <!DOCTYPE html> <html lang="en"> <?php include("includes/head.php"); ?> <!-- Preloader --> <div id="preloader"> <div id="status"> </div> </div> <body> <div id="sb-site"> <!-- header-full --> <div class="boxed"> <?php include ("../includes/header.php");?> <?php include("../includes/menu.php");?> </div> <!-- header-full --> <header class="main-header" style="background-color:#f1f1f1;"></header> <!-- container --> <div class="container"> <div class="row"> <!-- Sidebard menu --> <?php include ("../includes/adminsidebar.php"); ?> <!-- Sidebar menu --> <!--Container --> <div class="col-md-9"> <form role="form" action="<?php echo $editFormAction; ?>" name="add_post" method="POST"> <!-- Title --> <div class="form-group"> <label>Title</label> <input type="text" class="form-control" name="titulo" placeholder="Enter title"> </div> <!-- Title --> <!-- upload image --> <div class="form-group"> <input class='file' type="file" class="form-control" name="imagen" onClick="gestionimagen.php" id="images" placeholder="Please choose your image"> </div> <!-- Upload Image --> <div class="form-group"> <label> Description </label><br> <textarea class="" name="descripcion" style="width:100%"></textarea> </div> <!-- Text editors --> <div class="form-group"> <label> Contenido </label> <textarea class="ckeditor" name="contenido"></textarea> </div> <!-- Text editor --> <!-- Category --> <div class="form-group"> <label>Categoria</label> <input type="text" class="form-control" name="categoria" placeholder="Enter categoria"> </div> <div class="form-group"> <label>Tag</label> <input type="text" class="form-control" name="tag" placeholder="Enter tag"> </div> <!-- Category --> <!-- Visibilidad --> <div class="col-md-6" id="select"> <div class="form-group"> <label for="select">Visible</label> <select class="form-control" id="estatus" name="estatus"> <option value="1">Si</option> <option value="0">No</option> </select> </div> </div> <!-- Visibilidad --> <!-- Tiplo de Plantilla necesito trabajar en esto!!!!! pero ya!!!--> <script> function plantilla(){ var formData = new FormData($("#formUpload")[0]); $.ajax({ type: 'POST', url: 'plantillapost.php', data: formData, contentType: false, processData: false }); } </script> <div class="col-md-6" id="select2"> <div class="form-group"> <label for="select">Plantilla</label> <select class="form-control" id="plantilla" name="plantilla"> <option value="1" <?php if (!(strcmp(1, ""))) {echo "SELECTED";} ?>>Normal</option> <option value="2" onClick="plantilla" <?php if (!(strcmp(2, ""))) {echo "SELECTED";} ?>>Full-Width</option> </select> </div> </div> <!-- Tipo de Plantilla --> <div class="col-md-6" id="select"> <div class="form-group"> <label>Link</label> <input type="text" class="form-control" name="link" placeholder="Enter link"> </div> </div> <div class="col-md-6" id="select2"> <div class="form-group"> <label>Price</label> <input type="text" class="form-control" name="price" placeholder="Enter price"> </div> </div> <button type="submit" class="btn btn-ar btn-primary pull-right">Agregar</button> <input type="hidden" name="MM_insert" value="add_post"> </form> </div> <!-- Container --> </div> </div> <!-- container --> <?php include("../includes/footer.php");?> </div> <!-- boxed --> </div> <!-- sb-site --> <?php include("../includes/menuderecha.php");?> <!-- sb-slidebar sb-right --> <?php include("../includes/back-to-top.php");?> <!-- Scripts --> <!-- Compiled in vendors.js --> <!-- <script src="js/jquery.min.js"></script> <script src="js/jquery.cookie.js"></script> <script src="js/imagesloaded.pkgd.min.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/bootstrap-switch.min.js"></script> <script src="js/wow.min.js"></script> <script src="js/slidebars.min.js"></script> <script src="js/jquery.bxslider.min.js"></script> <script src="js/holder.js"></script> <script src="js/buttons.js"></script> <script src="js/jquery.mixitup.min.js"></script> <script src="js/circles.min.js"></script> <script src="js/masonry.pkgd.min.js"></script> <script src="js/jquery.matchHeight-min.js"></script> --> <script src="<?php echo $urlWeb ?>js/vendors.js"></script> <!--<script type="text/javascript" src="js/jquery.themepunch.tools.min.js?rev=5.0"></script> <script type="text/javascript" src="js/jquery.themepunch.revolution.min.js?rev=5.0"></script>--> <!-- Syntaxhighlighter --> <script src="<?php echo $urlWeb ?>js/syntaxhighlighter/shCore.js"></script> <script src="<?php echo $urlWeb ?>js/syntaxhighlighter/shBrushXml.js"></script> <script src="<?php echo $urlWeb ?>js/syntaxhighlighter/shBrushJScript.js"></script> <script src="<?php echo $urlWeb ?>js/DropdownHover.js"></script> <script src="<?php echo $urlWeb ?>js/app.js"></script> <script src="<?php echo $urlWeb ?>js/holder.js"></script> <script src="<?php echo $urlWeb ?>js/home_profile.js"></script> <script src="<?php echo $urlWeb ?>js/efectos.js"></script> </body> </html> But Im still not able to display it, si I tried to do a tutorial that I saw on Internet and it made do another php file, that why I put on the input an action="gestionimagen.php" otherwise I would have never done, here is my code for gestionimagen.php: NOTE: I had to create another table on my server called images, but I would like to be able to do it in my table called posts as I have in the code above. <?php require_once '../Connections/connection.php'; $data = array(); if( isset( $_POST['image_upload'] ) && !empty( $_FILES['imagen'] )){ $image = $_FILES['imagen']; $allowedExts = array("gif", "jpeg", "jpg", "png"); if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } //create directory if not exists if (!file_exists('imagen')) { mkdir('imagen', 0777, true); } $image_name = $image['name']; //get image extension $ext = strtolower(pathinfo($image_name, PATHINFO_EXTENSION)); //assign unique name to image $name = time().'.'.$ext; //$name = $image_name; //image size calcuation in KB $image_size = $image["size"] / 1024; $image_flag = true; //max image size $max_size = 512; if( in_array($ext, $allowedExts) && $image_size < $max_size ){ $image_flag = true; } else { $image_flag = false; $data['error'] = 'Maybe '.$image_name. ' exceeds max '.$max_size.' KB size or incorrect file extension'; } if( $image["error"] > 0 ){ $image_flag = false; $data['error'] = ''; $data['error'].= '<br/> '.$image_name.' Image contains error - Error Code : '.$image["error"]; } if($image_flag){ move_uploaded_file($image["tmp_name"], "../images/post".$name); $src = "../images/post".$name; $dist = "../images/post/thumbnail_".$name; $data['success'] = $thumbnail = 'thumbnail_'.$name; thumbnail($src, $dist, 200); $sql="INSERT INTO images (`id`, `original_image`, `thumbnail_image`, `ip_address`) VALUES (NULL, '$name', '$thumbnail', '$ip');"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } } mysqli_close($con); echo json_encode($data); } else { $data[] = 'No Image Selected..'; } ?> So I don't know if did properly explain myself, but thats what I want, send the picture to my server into my table called posts, otherwise can you help me how to properly adapt it to the new table called "images" .
  24. I got a page where user able to search data by filtering using datepicker(date range) or using dropdown selection option. There are two button on the page which are search button and print button. I want to pass the data which i have search to another page where i using mpdf. How to pass the searched value to another page(mpdf).. im using method POST for my form. what kind of unique ID or value that i can pass to another page?
  25. I'm not hoping to much that I can solve this thing, but maybe someone here who knows php well can help me. Screenshot: http://extrazoom.com/image-70122.html?heuln50x50 File: https://mega.nz/#!uYgWmRTL!5ZyabPKnYWjeG2sL_PXyfFaAKaJiv4zceQGrky7fmPk And yes, I replaced "preg_replace" with "preg_replace_callback" and I ended up here: Screenshot:: http://extrazoom.com/image-70124.html?heuln50x50 Thank you and sorry for my bad english, if it's bad .
×
×
  • 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.