Jump to content

Search the Community

Showing results for tags 'post'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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 (Dreamweaver, Zend, 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


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 13 results

  1. hello everyone, I have a php form, everything works, I do not carry any header() at the end of the form because I have to stay on the same page and because I feel it wipes out the message you sent the form successfully, but for this though if reloading the page shows me the popup asking me to resend the form. how can i solve? I found a function in js with replacestate but I saw that it doesn't work with mobile Safari. if ( window.history.replaceState ) { window.history.replaceState( null, null, window.location.href ); }
  2. Hi everyone, I hope cyberRobot or Guru is reading this thread. I am trying to create a vertical table data in php from method of GET and POST. Is it possible? I succeed created the vertical table data from database (MySQL). I created the vertical table data on php that inside the form thathas method of GET or POST, that should allow any value in php go to another page by method of GET, but seem it doesn't work. Maybe I miss something in code? Help will be very appreciate. I am still learning, ready to get in interaction in php. Here my code: <!doctype html> <html> <head> <title>Test array attendence</title> </head> <body> <table> <?php $columns = 2; if(isset($_GET['member'])) { $display = $_GET['member']; $num_row = $display; $rows = ceil($num_row / $columns); <-- It is causing an error in code, line 14. while ($row = $display) { $data[] = $row; } echo "<table border='1'>"; for($i = 0; $i < $rows; $i++) { echo "<tr>"; for($j = 0; $j < $columns; $j++) { if(isset($data[$i + ($j * $row)])) { echo "<td>".$data[$i + ($j * $row)]."</td>"; $count = $count+1; } } echo "</tr>"; } } ?> </table> <table><tr><td><?php echo $count." are attending this meeting tonight." ?></td></tr></table> </body> </html> I get an error message - Fatal error: Unsupported operand types in /srv/disk10/1141650/www/sigmahokies.biz.ht/testarray3.php on line 14
  3. Hi, I have been detecting POST submits as below if(isset($_POST['someindex']) && $_POST['someindex']==="somevalue"){ .. } which I know should be replaced by if($_SERVER['REQUEST_METHOD']=== "POST"){ ... } So I changed it in entirety in my project and on testing found that there are conflicts. Now my main file has a slider with a login and logoff button. and then when the user is logged in it includes the user page, which in turn keeps including other pages . So if there are many buttons on those pages, it can result in a conflict as I found out. I wish to confirm that to avoid the conflicts is the following the right way to go about it. I would like to say that while the index may be the same, the values for each are unique. if($_SERVER['REQUEST_METHOD']=== "POST" && if(isset($_POST['someindex']) && $_POST['someindex']==="somevalue")){ ... } Thanks all !
  4. This is posting to any row in mssql that has a matching 'start_date'. I would like it to post rows where start_date = '$start_date' and it also matches the 'meter_id' . It should perform this check of both parameters before posting to mssql. <?php $session_id = $_SESSION['id']; $comm_id = $_GET['meter_id']; $start_date = $_GET['start_date']; $payment_date = $_POST['payment_date']; $amount_paid = $_POST['amount_paid']; $check_number = $_POST['check_number']; $sql = "UPDATE [radiogates].[dbo].[ops_invoice_history] SET payment_date = '$payment_date', amount_paid = '$amount_paid', check_number = '$check_number' where start_date = '$start_date'"; $query = sqlsrv_query($conn, $sql); Thank you for any help.
  5. Hello, i am new to php and from this project i have started my php learning so first of sorry if my question is simple to ask but its difficult for me to understand the error and i want to learn php so i really need from all php expert available here. so i am getting error in generating news or latest post.. here is my code <? include("includes/connect.php"); $select_posts = "select * from posts order by rand() LIMIT 0,2"; $run_posts = mysql_query($select_post); while($row=mysql_fetch_array($run_post)){ $title = $row ['post_title']; $date = $row ['post_date']; $author = $row ['post_author']; $image = $row ['post_image']; $content = substr($row ['post_content'],0,200);+ } ?> <h2><?php echo $title; ?></h2> Following i am getting in my news page : Notice: Undefined variable: title in G:\wamp\www\rect\includes\news_data.php on line 16
  6. I have a timeclock application where you can add entries into a table. One of the columns is a <select> dropdown tag. If you do not enter one of the required fields, I redisplay the values entered so the user can correct the entries and resubmit to save them. Everything saves (posts) except the <select> dropdown value. The dropdown does show properly, even with the properly selected value. But if you change the value, it doesn't update. It retains the original value. Here is the function from STOP_Timeclock.php class that does the form: public function add_entries_page($msg) { $redisp = $_SESSION['redisp']; $out = ''; $offhrs = "N"; $dbh = new Database; //display the last entry the user saved to the database $dbh->query("SELECT * FROM Entries WHERE UID = :uid and GID = :gid order by Date DESC Limit 1"); $dbh->bind(':uid', $_SESSION['UID']); $dbh->bind(':gid', $_SESSION['GID']); $rows = $dbh->resultset(); foreach ($rows as $value) { $msg .= "Your last entry was: " . date('m-d-Y',strtotime($value['Date'])) . " for: " . $value['Description'] . " - " . number_format($value['Hours'],2,'.','') . " hour(s) were recorded. <br>"; } $select = $this->getGroupsForEntriesForm($_SESSION['UID']); //$select2 = $this->getGroupsForEntriesForm3($_SESSION['UID'],$_SESSION['array_category']); $caption = 'If you leave the Date Box empty, it defaults to today. *<b>Date/Category/Description/Hours are REQUIRED fields</b> <br><br>'; $head = array(array('name' => 'head', '1' => 'Date *', '2' => 'Ticket ID', '3' => 'Ticket Name', '4' => 'Category *', '5' => 'Description of Work Done *', '6' => 'Hours *', '7' => 'Off Hours(Y/N)' )); if($redisp == 0) { $body = array(); unset($_SESSION['array_id']); unset($_SESSION['array_name']); unset($_SESSION['array_category']); unset($_SESSION['array_desc']); unset($_SESSION['array_hours']); unset($_SESSION['array_offhrs']); for ($i = 1; $i < 11; $i++) { $row = array($this->xhtml->input(array('type' => 'text', 'id' => "datepicker$i", 'class' => 'entries_field_1', 'name' => 'DATE[]' )), $this->xhtml->input(array('type' => 'text', 'name' => 'ID[]', 'class' => 'entries_field_2' )), $this->xhtml->input(array('type' => 'text', 'name' => 'NAME[]', 'class' => 'entries_field_3' )), $select, $this->xhtml->input(array('type' => 'text', 'name' => 'DESC[]', 'class' => 'entries_field_5' )), $this->xhtml->input(array('type' => 'text', 'name' => 'HOURS[]', 'class' => 'entries_field_6' )), $this->xhtml->input(array('type' => 'text', 'name' => 'OFFHOURS[]', 'value' => $offhrs, 'class' => 'entries_field_7' )) ); $body[$i] = $row; } } if($redisp == 1) { $body = array(); $name = $_SESSION['array_name']; $id = $_SESSION['array_id']; $category = $_SESSION['array_category']; $desc = $_SESSION['array_desc']; $hours = $_SESSION['array_hours']; $offhrs = $_SESSION['array_offhrs']; $dates = $_SESSION['array_dates']; $max_count = $_SESSION['max_count']; for ($i = 0; $i < $max_count; $i++) { $selected = $this->getCatName($_SESSION['UID'], $category[$i]); $row = array($this->xhtml->input(array('type' => 'text', 'id' => "datepicker$i", 'class' => 'entries_field_1', 'value' => $dates[$i], 'name' => 'DATE[]' )), $this->xhtml->input(array('type' => 'text', 'name' => 'ID[]', 'value' => "$id[$i]", 'class' => 'entries_field_2' )), $this->xhtml->input(array('type' => 'text', 'name' => 'NAME[]', 'value' => "$name[$i]", 'class' => 'entries_field_3' )), "$selected", $this->xhtml->input(array('type' => 'text', 'name' => 'DESC[]', 'value' => "$desc[$i]", 'class' => 'entries_field_5' )), $this->xhtml->input(array('type' => 'text', 'name' => 'HOURS[]', 'value' => "$hours[$i]", 'class' => 'entries_field_6' )), $this->xhtml->input(array('type' => 'text', 'name' => 'OFFHOURS[]', 'value' => "$offhrs[$i]", 'class' => 'entries_field_7' )), ); $body[$i] = $row; if(isset($_POST['CAT'])) { $_SESSION['cats'][$i] = $_POST['CAT']; } else { $_SESSION['cats'][$i] = $category[$i]; } } } $data = array_replace($head, $body); $table = $this->xhtml->table2($data, $caption, array('class' => 'add_time')); $table .= $this->xhtml->input(array('type' => 'submit', 'value' => 'Add Entries' )); $form = $this->xhtml->form(array(array($table), ), array('action' => BASE . '/addEntries.php', 'class' => 'add_time', 'onsubmit' => 'return valid_Add(this)', 'method' => 'post' ) ); $out = $form; $menu = $this->getMenu(); $msg = $this->xhtml->div("$msg", array('id' => 'error')); $out = $this->xhtml->div("$out", array('id' => 'add_entries_form')); $out = $this->xhtml->div("$msg$out", array('id' => 'main')); $out = $this->xhtml->div("$menu$out", array('id' => 'container')); $out = $this->xhtml->body("$out", array('onload' => 'startUp();')); return $out; } And here is the addEntries page that evaluates for all fields and then saves to the database if correct. <?php session_start(); include('includes/config.php'); $msg =''; $x=0; $ok_to_post = 0; $page = new STOP_Timeclock; $xhtml = new XHTML; $dbh = new Database; if (isset($_POST['NAME'])) { $name = array_filter($_POST['NAME']); $_SESSION['array_name'] = $name; } if (isset($_POST['ID'])) { $id = array_filter($_POST['ID']); $_SESSION['array_id'] = $id; } if($_SESSION['redisp'] == 0) { if (isset($_POST['CAT'])) { $category = array_filter($_POST['CAT']); $_SESSION['array_category'] = $category; } } else { $category = $_SESSION['cats']; } if (isset($_POST['DESC'])) { $desc = array_filter($_POST['DESC']); $_SESSION['array_desc'] = $desc; } if (isset($_POST['HOURS'])) { $hours = array_filter($_POST['HOURS']); $_SESSION['array_hours'] = $hours; } if (isset($_POST['OFFHOURS'])) { $offhrs = array_filter($_POST['OFFHOURS']); $_SESSION['array_offhrs'] = $offhrs; } if (isset($_POST['DATE'])) { $dates = array_filter($_POST['DATE']); $_SESSION['array_dates'] = $dates; } $count_category = count($category); //$msg .= "count of category field is " . $count_category . "<br>"; $count_desc = count($desc); //$msg .= "count of desc field is " . $count_desc . "<br>"; $count_hours = count($hours); //$msg .= "count of hours field is " . $count_hours . "<br>"; $count_dates = count($dates); //$msg .= "count of date field is " . $count_dates . "<br>"; if ($count_desc == $count_hours) { if ($count_hours == $count_dates) { $ok_to_post = 1; $max_count = $count_desc; } else { if ($count_hours > $count_dates) { $max_count = $count_desc; } else { $max_count = $count_hours; } $ok_to_post = 0; $msg .= 'You did not enter one of the required fields - Date/Category/Description/Hours are REQUIRED. <br />'; } } else { if ($count_desc > $count_hours) { $max_count = $count_desc; } else { $max_count = $count_hours; } $ok_to_post = 0; $msg .= 'You did not enter one of the required fields - Date/Category/Description/Hours are REQUIRED. <br />'; } //$msg .= "max count is set to " . $max_count . "<br>"; $_SESSION['max_count'] = $max_count; //everything is entered correctly - now process and insert into the database $rowCount = 0; $today = date("Y-m-d"); $count = 0; if ($ok_to_post == 1) { $redisp = 0; $_SESSION['redisp'] = $redisp; $dbh->beginTransaction(); $myquery = "INSERT INTO Entries (`UID`, `GID`, `Date`, `CID`, `TicketNumber`, `TicketName`, `Description`, `Hours`, `OffHours`,`Created_Date`) VALUES (:uid, :gid, :date, :cid, :num, :name, :desc, :hrs, :offhrs, now())"; $dbh->query($myquery); for ($x = 0; $x < $max_count; $x++) { $dbh->bind(':uid', $_SESSION['UID']); $dbh->bind(':gid', $_SESSION['GID']); $dbh->bind(':date', $dates[$x]); $msg .= "category[x] is set to " . $category[$x] . "<br>"; $dbh->bind(':cid', $category[$x]); if (count($id)==0) { $dbh->bind(':num', NULL); } else { $dbh->bind(':num', $id[$x]); } if (count($name)==0) { $dbh->bind(':name', NULL); } else { $dbh->bind(':name', $name[$x]); } $dbh->bind(':desc', $desc[$x]); $msg .= "desc[x] is set to " . $desc[$x] . "<br>"; $dbh->bind(':hrs', $hours[$x]); $msg .= "hour[x] is set to " . $hours[$x] . "<br>"; $dbh->bind(':offhrs', $offhrs[$x]); $result = $dbh->execute(); if (!$result) { $msg .= "Saving entry to the database failed. Please see system administrator. <br />"; continue; } $count += $dbh->rowCount(); } if ($count != $max_count) { $dbh->cancelTransaction(); $msg .= 'An error occurred and all entries could not be added. <br /> For safety, this was rolled back and no entries were added. <br /> Please see system administrator. <br />'; } else { $dbh->endTransaction(); $dbh->query("SELECT * FROM Entries WHERE UID = :uid and GID = :gid and Created_Date >= :date2"); $dbh->bind(':uid', $_SESSION['UID']); $dbh->bind(':gid', $_SESSION['GID']); $dbh->bind(':date2', $today); $rows = $dbh->resultset(); $msg .= "Returned " . count($rows) . " entries successfully written to and retrieved from the database for you today. <br>"; $tothrs = 0; foreach ($rows as $value) { $msg .= "On " . date('m-d-Y',strtotime($value['Date'])) . " for " . $value['Description'] . " - " . number_format($value['Hours'],2,'.','') . " hour(s) were recorded. <br>"; $tothrs = $tothrs + $value['Hours']; } $msg .= "Total hours entered today = " . $tothrs . "<br>"; $msg .= "<br><br>"; } $dbh = NULL; $_SESSION['MSG'] = $msg; header('Location: ' . BASE); } else { $redisp = 1; $_SESSION['redisp'] = $redisp; $_SESSION['MSG'] = $msg; header('Location: ' . BASE); } ?> I am hoping that you all might be able to assist. Thanks in advance.
  7. How do add $_GET['return'] to get output $input['return'] like i have $input['username'] and add value null if no return url detected? <?php $errors = array(); /* Form is not submitted */ $input = array( 'username' => NULL, 'password' => NULL, 'remember' => NULL ); /* Form is submitted */ if(filter_has_var(INPUT_POST, 'submit')){ $defs_POST = array( 'username' => FILTER_SANITIZE_STRING, 'password' => FILTER_UNSAFE_RAW, 'remember' => FILTER_SANITIZE_STRING ); $input = filter_input_array(INPUT_POST, $defs_POST); if(empty($input['username'])){ $errors[] = 'Please enter your username.'; } if(empty($input['password'])){ $errors[] = 'Please enter your password.'; } } if(filter_has_var(INPUT_POST, 'submit') and empty($errors)){ print "Username = '".$input['username']."', Password = '".$input['password']."', Remember = '".$input['remember']."', Return = '".$input['return']."'"; /* if(!empty($input['return'])) redirect(urldecode($input['return'])); else redirect('index.php?do=home'); */ } print " <form method='post'> Username <input type='text' name='username' value='".$input['username']."'><br> Password <input type='text' name='password' value='".$input['password']."'><br> Remember me <input type='checkbox' name='remember' value='Yes'><br> <input type='submit' name='submit' value='SUBMIT'> </form>"; ?>
  8. Here's the code that deals with the client side: search.php <?php //testing if data is sent ok echo "<h1>Hello</h1><br>" . $_GET['search']; ?> This is the link I get after sending foo. http://www.family-line.dx.am/Community/index.php?&search=foo Is that mean it was sent, but I'm not processing it correctly? I'm new to the whole AJAX thing.
  9. Hi Folks, Firstly I am new, I have read several topics here and learned a lot, I would class myself as 'slightly better than basic', but my knowledge is mostly gained from reading code. I am making a simple POST form for work, the data gets inserted into MySQL, nice and easy, I can make it work if I write out the statement completely, BUT I need to make a new form, it will have HUNDREDS of input fields, I really don't want to write the code, and I figured programmatically is a good way to go anyway as forms change and new forms may be required, so I set about building a function to completely handle my post data, bind it to a statement and insert it into a table, I have scrapped it a half dozen times already because something fundamentally doesn't work, but I am very close! The function can write the statement, but I need to bind the POST values before I can insert, something going wrong here and I would appreciate some help, I have a feeling it's a problem with an array, but anyway I will show you what I have, give you some comments as to my reasoning, and hopefully you can help me with the last bit public function getColumnNames($table){ $sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = :table"; try { $stmt = $this->dbh->prepare($sql); $stmt->bindValue(':table', $table, PDO::PARAM_STR); $stmt->execute(); $output = array(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ $output[] = $row['COLUMN_NAME']; } $all = array($output); $a1 = array_slice($output, 1); // I don't want column 1, it contains the ID, its auto incremented. $a2 = array_slice($a1, 0, -3); // I don't want the last 3 columns as they have default values $selected = array($a2); // contains all the columns except those excluded by array_slice, columns now match all of the input fields on the form foreach ($selected as $row){ $fields = "`" . implode('`, `', $row) . "`"; // I'm making `fields` here, $bind = ":" . implode(', :', $row); // And making :values here } return array ( "raw" => $all, "fields" => $fields, "bind" => $bind ); } catch(PDOException $pe) { trigger_error('Could not connect to MySQL database. ' . $pe->getMessage() , E_USER_ERROR); } } public function addRecord(){ $col = array(); $col = $this->getColumnNames("table"); $raw = array($col['raw']); $fields = array($col['fields']); $bind = array($col['bind']); $columnList = implode('`, `', $fields); $paramList = implode(', ', $bind); $sql = "INSERT INTO `{$this->dbtable}` ($columnList) VALUES ($paramList)"; return $sql; // this returns something like: INSERT INTO `table` (`field1`, `field2`, `field3`) VALUES (:field1, :field2, :field3)"; perfect I thought, now I just need to bind the values from $_POST... then I get stuck.
  10. Hello, i would like to know to how to make this script work. I get information using this link below in index.php, after i get the information i want to insert/update in database information which i don't show on the page self. index.php <?php echo '<a href="example.com?url='. $row['url'] . '&name='. $row['name'] .'&info='. $row['info'] .'&privat='. $row['privat'] .'" target="_blank">Edit</a> ';?> So like this here below i show the information. get_info.php <?php echo $_GET['name']; ?> Which works fine. So now updating the database. $ip_address = $_SERVER['REMOTE_ADDR']; // Ip address works fine $name = $_GET['name']; // not working $r_name = $_POST['$name']; // not working $r_name= 'test'; // this is working. mysql_query("insert into r_test (r_name,r_ip) values('$r_name','$ip_address')") or die(mysql_error()); So how can i get the value and insert in database, only row r_ip is updated with the ip address. I hope i explained it well Thanks in advance.
  11. Hi everybody! I am building a custom PHP app, and am submitting a form. This form will have between 1 or more textareas, named "textarea1", "textarea2", "textarea200", and so on. I need to read each of these and insert them into a database. How can I script this into the PHP landing page? Is there a way to read all of the values, and names, that are contained in $_POST. Many thanks, Jason
  12. I am trying to create a page for customers to enter their details. I am using a html form. When the submit button is pressed the form posts the inputs to the same page, which then checks if the inputs are empty. If they are not then each post variable is allocated a session variable so this info can be accessed late on in the system. If some of the inputs are empty then the value of the input forms become equal to the session variables that they were just allocated to so that the customer doesn’t have to retype their information. This is where the problem occurs. When I load the page each input box has a slash inside it and when the submit button is pressed a mother slash is added. My code is below: <?php session_start(); if(isset($_POST['NextPage'])){ if (!empty($_POST['CName'])){ $_SESSION["CName"] = $_POST['CName']; if (!empty($_POST['CStreet'])){ $_SESSION["CStreet"] = $_POST['CStreet']; if (!empty($_POST['CTown'])){ $_SESSION["CTown"] = $_POST['CTown']; if ($_POST['Counties'] != "-"){ $_SESSION["CCounty"] = $_POST['Counties']; if (!empty($_POST['CPostcode'])){ $_SESSION["CPostcode"] = $_POST['CPostcode']; if (!empty($_POST['CEmail'])){ $_SESSION["CEmail"] = $_POST['CEmail']; if (!empty($_POST['CNumb'])){ $_SESSION["CNumb"] = $_POST['CNumb']; $NotEmpty = true; }else{ $ErrorMsg = "Number is empty. </br>"; } }else{ $ErrorMsg = "Email is empty. </br>"; } }else{ $ErrorMsg = "Postcode is empty. </br>"; } }else{ $ErrorMsg = "County is empty. </br>"; } }else{ $ErrorMsg = "Town is empty. </br>"; } }else{ $ErrorMsg = "Street is empty. </br>"; } }else{ $ErrorMsg = "Name is empty. </br>"; } } $content = ' <h3 id="CTitle"> Customer Details </h3> <p><i>'.$ErrorMsg.'</i></p> <form action=" " method="POST" name="CDetails" id="CDetails"> Name: * <input type="text" name="CName" size="30" value='.$_SESSION["CName"].'/></br> First line of your address: * <input type="text" name="CStreet" size="40" value='.$_SESSION["CStreet”];.’/></br> Town: * <input type="text" name="CTown" size="25" value='.$_SESSION["CTown"].'/></br> Postcode: * <input type="text" name="CPostcode" size="11" value=‘.$_SESSION["CPostcode"].'/></br> Email address: * <input type="text" name="CEmail" size ="35" value='.$_SESSION["CEmail”];.’/></br> Phone Number: * <input type="text" name="CNumb" value='.$_SESSION["CNumb"].'/></br> <input type="submit" name="NextPage" value="Next" id="Next”/> </form> ?>
  13. Codeigniter POST request empty. I tried to up my website on our production server which is using IIS8, post request is empty, I've tried to break codeigniter and post is working. It is also working on our staging server which is on IIS6. Does anyone has an issue on this on Codeigniter 3.
  • 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.