Jump to content

Search the Community

Showing results for tags '$_post'.

  • 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 17 results

  1. I have an index.php file which includes my form and code to move the user's uploaded file to s3. My HTML form calls a js function sendEmails() which makes an AJAX request to another php script dbSystem() to validate the emails input and add it to a database. Everything is working except that the php code in my index.php file (at the very bottom) does not execute. It's supposed to execute when the user uploads a file and presses submit but it doesn't go into the if statement. I tried putting the $fileName = basename($_FILES["fileName"]["name"]) statement before the if statement but I get an undefined index error. I put my a comment in my code to show which if statement I am talking about. This is my HTML code in index.php: <form action="javascript:void(0)" method="POST" id="files" enctype="multipart/form-data"> <label class="col-md-4 col-form-label text-md-right">Select File: <span class="text-danger">*</span></label> <input type="file" id="userFile" name="fileName" style="cursor: pointer; max-width: 170px;" onchange="enableBtn()"> <label class="col-md-4 col-form-label text-md-right">Authorized Users: <span class="text-danger">*</span></label> <input placeholder="Enter e-mail(s) here..." id="req" autocomplete="off"/> <button id="submitBtn" name="submitBtn" class="<?php echo SUBMIT_BUTTON_STYLE; ?>" onclick="return sendEmails()" disabled>Submit</button> </form> This is my php code in index.php: <?php $conn = new mysqli($servername, $username, $password, $db); $sql = "SELECT sender_id, sender_email, receiver_emails, receiver_ids, file_name from filedrop_logs"; $result = mysqli_query($conn, $sql); if ($result) { echo "<div class='outputDiv'>"; echo "<table id='sharedOthers'>"; echo "<thead><tr class='headings'>"; echo "<th class='files'>Files</th>"; echo "<th class='users'>Users</th>"; echo "</tr></thead>"; while ($row = mysqli_fetch_assoc($result)) { $receiverEmails = $row['receiver_emails']; $fileName = $row['file_name']; echo "<tbody id='bodyOthers'>"; echo "<tr id='rowOthers'>"; echo "<td>$fileName<br>"; $objects = getListofObjects('FileDrop'); foreach ($objects as $object) { $file = $object['Key']; $splits = explode('/', $file); if (end($splits) !== '') { $presignedUrl = getPresignedUrlForPrivateFile($object['Key'], '+20 minutes'); $link = '<a href="'.$presignedUrl.'">Download</a>'; echo $link; } } echo "&nbsp;&nbsp;&nbsp;&nbsp;<a href=''>Delete</a></td>"; echo "<td>$receiverEmails</td>"; echo "</tr></tbody>"; } echo "</table></div>"; } ?> <?php //the if statement below doesn't execute if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES["fileName"])) { $fileName = basename($_FILES["fileName"]["name"]); $error = $_FILES["fileName"]["error"]; $tmpName = $_FILES["fileName"]["tmp_name"]; if (isset(fileName) && $fileName != '' && $tmpName != '' && sys_get_temp_dir()) { $separator = DIRECTORY_SEPARATOR; $newDir = sys_get_temp_dir() . $separator . "FileDrop" . microtime(true); if (!file_exists($newDir)) { mkdir($newDir, 0777, true); // creates temp FileDrop directory $tempFilePath = $newDir . $separator . $fileName; // creates temp file inside FileDrop directory if (move_uploaded_file($tmpName, $tempFilePath)) { // moves file to tmp folder $s3FileName = "FileDrop" . substr($newDir, 4) . $separator . $fileName; $result = putFileToS3($s3FileName, $tempFilePath, 'public-read'); deleteDir($newDir); } } } } ?> This is my js code in case you want to see it: function sendEmails() { var fileData = $('#userFile').prop('files')[0]; var formData = new FormData(); formData.append('tags', JSON.stringify(tags)); formData.append('fileName', fileData); $.ajax({ type: "POST", url: "../FileDrop/dbSystem.php", processData: false, contentType: false, data: formData, success: function(result) { result = JSON.parse(result); if (result.validity === "valid emails") { location.reload(); resetInputs(); //IMPORTANT $(".outputDiv").show(); } else { var tagsBrackets = result.emails.toString().replace(/[\[\]']+/g,''); var tagsQuotes = tagsBrackets.replace(/['"]+/g, ''); var tagsInvalid = tagsQuotes.replace(/,/g, ", "); $('#alertModal').modal({show:true}); document.getElementById('invalid').textContent = tagsInvalid; } } }); return false; } I've been stuck on this for so long, so I'd really appreciate the help!!
  2. Hi I want to echo out something when I post the value of a radio button and this value matches the same name of a html file. How can I formulate my code to achieve that? What I have so far: <?php if (isset($_POST['submitradio'])) { $selected_dir = $_POST['radio1']; echo substr($selected_dir, 0, -4); echo '<img src="'.$selected_dir.'" />'; } ?> So far I get for example the name of the image(order.gif) and the image order. gif. What I now want is to formulate my code so that I can say if I have an image called "order.gif" and a file called "order.html" that I can then echo out some thing. I don't want to actually name the image or the html file. I just want to say if I have two different file types that start with the same name then I can echo out what ever. How can I do that?
  3. Is it possible for a clickable image to pass to a php page? It can lead to a linked web page, so can it be like a submit button on a form and pass to the $_POST in php?
  4. I have a Google Adsense code that I am saving to the wp_options table. I can successfully save and retrieve the variable containing the google adsense code but it doesn't do anything except display it as plain text on screen. How can I make this html/javascript in the variable actually load in page as HTML/JS instead of as plain text??? this is the example of the code that I'm saving to the database and retrieving.... <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- EggSquat main banner ad --> <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-XXXXXXXXXXXXXXXX" data-ad-slot="XXXXXXXX"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> ....... may I should make a custom post type and just display a post, and use that instead of a single field saving to database
  5. Hi, I am a curious fellow just beginning to use PHP. I understand the basics of what the $_GET and $_POST superglobals do, and how we can use them to retrieve data after form submission. I also know that since $_GET and $_POST are just associate arrays, we can create our own values in both $_GET and $_POST by writing statements like $_POST['variable'] = "value". I am wondering if it is at all possible to send data beyond form data by adding new key/value pairs into $_GET and $_POST. So for example, if I had a form that transferred username/password through Post, would it be possible for me to include further data by just saying $_POST['formtype'] = "house_insurance_form"? Basically what I'm getting at is trying to physically add your own data to $_POST or $_GET that you could pull from the next page where the form redirects to. In other words, can I send data beyond form data using these superglobals? I know I can do this with $_SESSION, but could I do it through $_POST or $_GET? I haven't been able to accomplish this, and I was just wondering if someone could give me an in-depth explanation of how this might work or how this is not possible. I would really really really appreciate it. Best Regards, -Sky
  6. php newbie, have spent days trying to fix this so I hope somebody can put me out of my misery! I'm using WP + Advanced Custom Fields. I have a Custom Post Type (Minutes) which has either Draft or Approved posts. I'm trying to iterate the data to find Draft items and offer the option of changing to Approved. My code has extracted 3 Draft items. It's showing the 3 radio button groups. Problem: I cannot find how to get 3 values of 'status'. I either get a single value of '0', or '1' if any of the 3 radios is entered checked. The debug print_r & echo is showing: Array ( [0] => Array ( [postid] => 2557 [count] => 0 ) [1] => Array ( [postid] => 2545 [count] => 1 ) [2] => Array ( [postid] => 2541 [count] => 2 ) ) Key: 0, Value: 1 Here's my code: <?php /** * Template Name: Approve Minutes * * Print posts of a Custom Post Type. */ get_header(); ?> <div id="container"> <div id="content"> <?php $type = 'minutes'; $args = array ( 'post_type' => $type, 'post_status' => 'publish', 'paged' => $paged, 'posts_per_page' => -1, 'ignore_sticky_posts'=> 1 ); $temp = $wp_query; // assign ordinal query to temp variable for later use $wp_query = null; $wp_query = new WP_Query($args); $draftcount = 0; if ( $wp_query->have_posts() ) : ?> <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); if( !get_field('rdc_appstatus') ) // Test if false (=Draft) {$metastatus = "Draft";} else {continue;} $post_id = get_the_ID(); $posttitle = get_the_title(); $metafile = get_field('rdc_filename'); ?> <div class="span2 approve"> <form action="#" method="post"> <table> <tr><td><label><input id="toggle" type="radio" name="status[]" value="0" checked/>Draft</label></td></tr> <tr><td><label><input id="toggle" type="radio" name="status[]" value="1" />Approved</label></td></tr> <tr><td colspan="3" align="center"><input type="submit" name="submit" value="Confirm"/></td></tr> </table> </form> </div> <?php $drafts[$draftcount] = array ( 'postid' => $post_id, 'count' => $draftcount ); $draftcount++; endwhile; echo '<h3> '.$draftcount.' Draft Items Found</h3>'; ?> </ul> </div> <?php if (isset($_POST['status'])) { print_r ( $drafts); while (list($key,$value) = each($_POST['status'])) { echo "Key: $key, Value: $value <br />"; } } ?> <?php else : echo '<h3>No Draft Items Found</h3>'; endif; $wp_query = $temp; ?> </div><!-- #content --> </div><!-- #container --> <?php get_sidebar(); ?> <?php get_footer(); ?>
  7. Hey everyone, I wrote a Caesar cipher (a script where, given a message, the letters in the message are shifted x number of places; e.g. A => D, B => E, C => F, X => A, Y => B, Z => C, etc.). It works but it shifts all ASCII characters. I want to exclude characters that are not A-Z or a-z (outside the ASCII values of 65 - 90 and/or 97 - 122) so that spaces, punctuation, numbers all remain the same instead of shifting as well. Here's the form on index.html <form class="form-inline" role="form" method="post"> <div class="table-responsive"> <table> <tr class="tr_top"> <td class="td_top"><textarea class="form-control" rows="4" name="msg" placeholder="Your message here." onfocus='this.select()'><?php require ('encode.php'); require ('decode.php'); if (isset($_POST['encode'])) { echo $encstring; } elseif (isset($_POST['decode'])) { echo $decstring; } ?></textarea></td> </tr> <tr class="tr_mid"> <td class="td_mid"><input type=text class="form-control input_mid" name="offset" value="<?php if (isset($_POST['encode']) || isset($_POST['decode'])) { echo htmlspecialchars($_POST['offset']);} ?>" placeholder="Enter a number." pattern="[0-9]{0,3}" oninvalid="setCustomValidity('Please enter a number between 1 and 999.')" oninput="setCustomValidity('')"></td> </tr> <tr class="tr_bottom"> <td class="td_bottom"> <input class="input_bottom btn btn-default submit" type="submit" name="encode" value="Encode"> <input class="input_bottom btn btn-default submit" type="submit" name="decode" value="Decode"> <input class="input_bottom btn btn-default" type="button" value="Clear"</td> </tr> </table> </div><!-- close table-responsive --> </form> <?php //encode require ('encode.php'); if (isset($_POST['encode'])) { echo "<p>Original message:</p>"; echo "<p class='string ital'>" . $string . "</p>"; echo "<p>Encoded message:</p>"; echo "<p class='string ital'>" . $newstring . "</p>"; } //decode require ('decode.php'); if (isset($_POST['decode'])) { echo "<p>Encoded message:</p>"; echo "<p class='string ital'>" . $string . "</p>"; echo "<p>Decoded message:</p>"; echo "<p class='string ital'>" . $newstring . "</p>"; } ?> and here is encode.php <?php $string = $_POST['msg']; $newstring = $string; $sp = $_POST['offset']; for ($i=0; $i < strlen($string); $i++) { $ascii = ord($string[$i]); for ($j=0; $j < $sp; $j++) { if ($ascii == 90) { //uppercase bound $ascii = 65; //reset back to 'A' } else if ($ascii == 122) { //lowercase bound $ascii = 97; //reset back to 'a' } else { $ascii++; } } $newstring[$i] = chr($ascii); $encstring = $newstring; } ?> Any help would be appreciated as I can't figure it out. If you want to see it in action it's here.
  8. so i have problem with using mysql and php. i wanted to create a guestbook using a table which has: id,date, name,mail,txt and ip. and then i wrote this: <?PHP $connect = mysql_connect("localhost","",""); mysql_select_db("site1",$connect); mysql_query("SET NAMES utf8") or die(mysql_error()); $read = mysql_query('SELECT * FROM guestbook ORDER BY date ') or die(mysql_error()) ; $mass = mysql_fetch_array($read); ?> </head> <body> <form action='bb.php?click' method='post'> name:<input type="text" name="name" /><br /> mail:<input type="text" name="mail" /><br /> comment:<textarea name="txt" rows="7"></textarea><br /> adress <input type='submit' value='ENTER' /> </form> <?PHP if(isset($_GET['click'])) { $date = date("Y-m-d"); $mass['ip'] =$_SERVER['REMOTE_ADDR']; $_POST['mail'] = htmlspecialchars($_POST['mail']); $_POST['mail'] = stripslashes($_POST['mail']); $_POST['mail'] = trim($_POST['mail']); $ins = mysql_query("INSERT INTO guestbook(name,mail,txt) VALUES('$_POST[name]','$_POST[mail]','$_POST[txt]')"); if(isset($ins)) {echo $mass['name']." ";echo $mass['mail']." ";echo $mass['date']."<br />"; echo $mass['text']."<br />"; echo "<hr width=100% />"; } else echo mysql_error(); } ?> and after i insert and submit something it doesnt recognize the $_POST variables because the they dont exist anymore so what should i do???
  9. I have the following: .. This is the button with hidden type .. <input type="hidden" name="s2member_pro_paypal_registration[nonce]" id="s2member-pro-paypal-registration-nonce" value="xxx"> <input type="hidden" name="s2p-option" value=""> <input type="submit" name="r_submit" id="s2member-pro-paypal-registration-submit" class="s2member-pro-paypal-submit s2member-pro-paypal-registration-submit" value="Register" tabindex="1000"> My code to detect the submit button: if (!isset($_POST['r_submit']) && $_POST['s2member_pro_paypal_registration']['nonce'] == 'xxx') { // Do nothing } else { var_dump($something); // Do something } My site spits out var_dump() automatically when the form hasn't been submitted yet and I'm not sure why. Can someone please help me? Thanks, Hal
  10. Hi, I'm running into an issue retrieve data values from a registration submission form. The form is using a POST method Please see code below. More codes above, just a small snippet ... <div id="s2member-pro-paypal-registration-form-email-div" class="s2member-pro-paypal-form-div s2member-pro-paypal-registration-form-div s2member-pro-paypal-form-email-div s2member-pro-paypal-registration-form-email-div"> <label for="s2member-pro-paypal-registration-email" id="s2member-pro-paypal-registration-form-email-label" class="s2member-pro-paypal-form-email-label s2member-pro-paypal-registration-form-email-label"> <span><?php echo _x ("Email Address", "s2member-front", "s2member"); ?> </span><span class="red-asterik">∗</span><br /> </label> <input type="text" aria-required="true" data-expected="email" maxlength="100" autocomplete="off" name="s2member_pro_paypal_registration[email]" id="s2member-pro-paypal-registration-email" class="s2member-pro-paypal-email s2member-pro-paypal-registration-email" value="%%email_value%%" tabindex="40" /> </div> ... <div id="s2member-pro-paypal-registration-form-submit-div" class="s2member-pro-paypal-form-div s2member-pro-paypal-registration-form-div s2member-pro-paypal-form-submit-div s2member-pro-paypal-registration-form-submit-div"> %%hidden_inputs%% <!-- Auto-filled by the s2Member software. Do NOT remove this under any circumstance. --> <input type="submit" name="registration_submit" id="s2member-pro-paypal-registration-submit" class="s2member-pro-paypal-submit s2member-pro-paypal-registration-submit" value="<?php echo esc_attr (_x ("Register", "s2member-front", "s2member")); ?>" tabindex="400" /> </div> <div style="clear:both;"></div> </div> For this example, I have the following: // Store POST data into a variable $email = esc_attr($_POST['s2member_pro_paypal_registration[email]']); // Detect Submission if (!isset($_POST['registration_submit'])){ // Do nothing } else { // Check it var_dump($email); } This seems like it's correct but I wasn't able to retrieve the POST data and var_dump() was returning an empty string. Does anyone know why and should I post up more codes for more assistance? Thank you, Hal
  11. Hello people! Yes, I'm here again for a serious mattter. I've been trying to display a value from the table I've created in my database, it's teacher profiling system which functions enables the user to ADD, UPDATE, and VIEW the teacher's profile. So first let me introduce my novice codes... First, I let the user to insert data into table with this- <form method=post action=process_add_tchr_profile.php> <p align="left"><input type=number name=tchr_id placeholder="Teacher ID" required></p> <p><input type=text name=tchr_lname placeholder="Last Name" required> <p><input type=submit value=Submit><input type=reset value=Reset></p> </form> Second, after submission it will be processed and stored in- $connection = mysql_connect("localhost", "root", ""); $db = mysql_select_db("snnhs_db", $connection); $sql="INSERT INTO snnhs_db.tbl_tchr_profl( `tchr_id`, `tchr_lname`,) VALUES ('".$_POST["tchr_id"]."', '".$_POST["tchr_lname"]."',)"; $result = mysql_query($sql); Third, in my html, I put an action where user can update the profile of the teacher- $dbconnect = mysql_connect("localhost","root",""); mysql_select_db("snnhs_db",$dbconnect); $sql = "SELECT * FROM tbl_tchr_profl"; $result = mysql_query($sql); $ctr = 0; while($row = mysql_fetch_array($result,MYSQL_NUM)){ for($x=0;$x<count($row);$x++){ $tchr_profl[$ctr][$x] = $row[$x]; } $ctr++; } <h3>List of Accounts</h3> <a href=#>Add New Account</a> <table border=1 cellpadding=5> <tr> <th>No</th> <th>Teacher ID</th> <th>Last Name</th> <th>Action</th> </tr> <?php $ctr = 1; for($x=0;$x<count($tchr_profl);$x++){ echo "<tr>"; echo "<td>".$ctr++."</td>"; echo "<td>".$tchr_profl[$x][0]."</td>"; echo "<td>".$tchr_profl[$x][1]."</td>"; echo "<td><a href=update_tchr_profl.php?id={$tchr_profl[$x][0]}>UPDATE</td>" } Fourth, after clicking the UPDATE it will be redirected to update_tchr_profl.php where I have this code- <?php $dbconnect = mysql_connect("localhost","root",""); mysql_select_db("snnhs_db",$dbconnect); $sql = "SELECT * FROM tbl_tchr_profl WHERE tchr_id ={$_GET["id"]}"; $result = mysql_query($sql); $ctr = 0; while($row = mysql_fetch_array($result,MYSQL_NUM)){ for($x=0;$x<count($row);$x++){ $tchr_profl[$ctr][$x] = $row[$x]; } $ctr++; ?> <p align="left">"<?php ".$_POST["tchr_id"]."?>"</p> -- here I want to display the ID since it can't be updated. <p><input type=text name=tchr_lname value=<?php '".$_POST["tchr_lname"]."' ?> required> -- here I want to display the current data of the last name from the first time it registers to the system This is my problem, I don't if it's possible or what. I've searched through the internet but I don't seem to understand much about what they're saying so I decided to post my codes for me to better understands it. Sorry about codes and if you ask me who teach me why did I came up with such code, well, it's just what I thought to be, because I thought it would work.
  12. hey all, i am a bit lost on this one. i have a single php page it has a login form a submit new timesheet form and a display my timesheets table. this is updated as soon as the user submits a new timesheet. my issue is, after a timesheet has been submitted once, the table will add a row from the database and its great. but if i page refresh, it submits another identical timesheet. this happens even if i unset all the post variables. what is the best resolution. is there some kind of cookie i have to use? i'd rather avoid cookies. i'd also rather avoid having a second php file. i dont fully understand the $_POST variable concept. why are they not unset?
  13. I don't know how to fix this. It worked in 4.3 php, then my server got upgrade to 5.0 , then I have this error , how do I fix this. Thanks if you read this. it might be 5.3 php now Warning: file() [function.file]: Filename cannot be empty in (directory) at line 24. So here is my line24 24 $answerarray = file($_POST['answerfile'] );
  14. Hi php Freaks XD I have a small problem. I have a form that i would like to make it so i can add a column to my table on my site. but the form that fills our the stuff, when i press the submit button i don't get a response. Here is a rly simple code that i can't get to work. When i press the button it should say "success", and if the textbox is empty it should say "error". simple right? Well i can't get any response what so ever. here is the code in simpel. if(isset($_POST['addTableBtn'])){ if(empty($_POST['addTableText'])){ echo "Error"; }else{ echo "Success"; } } and the submit button name and textbox name match, i have checket.
  15. how to print a pdf label from the data which i have stored in a mysql database? to pull all the data from database where user_id is = $_POST
  16. When a user browses through my client's merchandise, they should be able to click on a product image at any time to retrieve a description, details, and larger image(s), of the product. Given the way the site is constructed, it will require a query to the database, and I would like for it to open in a new window so that the shopper does not lose their place. I have a general plan for how to accomplish this. Each product will need a dynamically generated link/submit button. It will open in a new window by using the target='_blank' attribute. I can use either post or get to query the product ID which will allow the new script to query the DB and echo the results to the page. My question is, are there any security risks? This website is generally pretty secure as the only customer input is unsigned integers, and all the get/post requests are validated. Since this is my first cart I just wanted to see if there are any recommended best practices or potential vulnerabilities for which I should plan.
  17. Here is a row from my merchandise table: <tr> <td>Product ID</td> <td>Artist</td> <td>Title</td> <td>Album Art</td> <td>Label</td> <td>Year</td> <td>Price</td> <td> <input type='text' name='cart[dawn of chaos][]' value='0' size='2'/> </td> </tr> I would like to direct your attention to the input row. In my PHP, the input field actually says "name=cart[$title][]" etc... Then I would like to reference the multidimensional array with PHP. To begin I just added a simple foreach. foreach($_POST['cart'] as $item){ echo $item; } PHP says this: Array ( ) Notice: Undefined index: cart in /you/probably/don't/need/my/filepath/cart.php on line 6 Warning: Invalid argument supplied for foreach() in....
×
×
  • 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.