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


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 (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

    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. 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 !
  2. 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.
  3. 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
  4. 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
  5. I want to edit an xml using PHP and POST from iOS app. The XML Looks like: <?xml version="1.0" encoding="UTF-8"?> <rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> <channel> <atom:link rel="self" type="application/rss+xml" href="http://www.316apps.site90.net/Test.xml"/> <lastBuildDate>Mon, 3 Feb 2014 09:26:14 -0500</lastBuildDate> <title>Prayer Warrior</title> <description><![CDATA[Prayer Warrior]]></description> <link>http://www.316apps.site90.net</link> <language>en</language> <copyright>2014 Prayer Warrior</copyright> <item> <first_name>John</first_name> <last_name>Doe</last_name> <title>I need money</title> <date>Mon, 3 Feb 2014 09:26:14 -0500</date> <anonymous>No</anonymous> <prayer_warriors>1</prayer_warriors> <location>USA</location> </item> <item> <first_name>Jane</first_name> <last_name>Doe</last_name> <title>I need money</title> <date>Tue, 4 Feb 2014 09:26:14 -0500</date> <anonymous>No</anonymous> <prayer_warriors>1</prayer_warriors> <location>USA</location> </item> </channel> </rss> Over time, the XML will grow. In my iOS app I have a UITableView that parses the XML into different rows. When they view a row, I want it to increase the count on the prayer. PHP I am using now is: <?php $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $title = $_POST['title']; $xml = simplexml_load_file("http://www.316apps.site90.net/Test.xml") or die("Not loaded!\n"); $responses = $xml->xpath("//channel/item[title = $title and first_name = $first_name and last_name = $last_name]/prayer_warriors"); $responses[0][0] = $responses[0] + 1; print_r($responses); $xml->asXML("Test.xml"); ?> The iOS app uses this code for POST to it: RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row]; NSString *myRequestString = [NSString stringWithFormat:@"first_name=%@&last_name=%@&title=%@", entry.firstName, entry.lastName, entry.prayerRequest]; // Create Data from request NSData *myRequestData = [NSData dataWithBytes: [myRequestString UTF8String] length: [myRequestString length]]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: @"http://www.316apps.site90.net/Increase.php"]]; // set Request Type [request setHTTPMethod: @"POST"]; // Set content-type [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"]; // Set Request Body [request setHTTPBody: myRequestData]; // Now send a request and get Response NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil]; // Log Response NSString *response = [[NSString alloc] initWithBytes:[returnData bytes] length:[returnData length] encoding:NSUTF8StringEncoding]; NSLog(@"Response%@",response); However, nothing changes, and I get an invalid predicate message on the response on my iPhone for the line: $responses = $xml->xpath("//channel/item[title = $title and first_name = $first_name and last_name = $last_name]/prayer_warriors"); Thoughts?
  6. dave25

    POST and GET help

    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>"; ?>
  7. 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.
  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. Hi there, I've built a form that should generate an e-mail, but it's not working properly. At first the page wouldn't display at all due to a problem with the EOD tags, that's fixed and I can now see a page, but when I type something in and hit submit, it's just not doing what it's supposed to do. Like I said it's supposed to e-mail me the data and leave the form filled with the data just submitted; it's doing neither. It is however posting the info into the address bar, so something is happening at least. here's a link to the page: http://www.remembertheprojector.com/php/testform.php here's the code: <?php if ($_POST['parse_var'] == "testform"){ $emailtitle = 'New E-mail'; $youremail = 'junk@remembertheprojector.com'; $namefield = $_POST['name']; $emailfield = $_POST['email']; $messagefield = $_POST['message']; $body = <<<EOD <br><hr><br> Name: $namefield <br /> Email: $emailfield <br /> Message: $messagefield <br /> EOD; $headers = "From: $emailfield\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail("$youremail", "$emailtitle", "$body", "$headers"); $sent = "Thank you!"; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/xml; charset=utf-8" /> <title>Contact Form</title> </head> <body> <table width="400" border="1" cellpadding="0" align="center"> <tr> <td align="center">Contact me? <br /> <br /> <form id="contactform" name="contactform" methord="post" action="testform.php"> <table width="100%" border="0" cellpadding="3"> <tr> <td width="25%" align="right">Name:</td> <td width="75%"> <label for="name"></lable> <input type="text" name="name" id="name" maxlength="30" size="30" value="<?php print "$namefield"; ?>" /> </td> </tr> <tr> <td width="25%" align="right">Email:</td> <td width="75%"> <label for="email"></lable> <input type="text" name="email" id="email" maxlength="50" size="50" value="<?php print "$emailfield"; ?>" /> </td> </tr> <tr> <td width="25%" align="right">Message:</td> <td width="75%"> <label for="message"></lable> <textarea name="message" id="message" cols="40" rows="5"><?php print "$messagefield"; ?></textarea> </td> </tr> <tr> <td width="25%"></td> <td width="75%" align="right"> <input type="reset" name="reset" id="reset" value="reset" /> <input type="hidden" name="parse_var" id="parse_var" value="testform" /> <input type="submit" name="submit" id="submit" value="submit" /> </td> </tr> <tr> <td width="100%"><?php print "$sent"; ?></td> </tr> </table> </form> </td> </tr> </table> </body> </html> Also attached is a screen shot of the php so you can see how it's tabbed. Thanks for any help.
  11. 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.
  12. So I have an AJAX call that I'm using to POST 1 variable to a PHP script I have on a separate server. The PHP takes this variable and returns data based off of what the variable is. This works on all browsers except IE9 and below. IE9 returns data but it's an error saying the variable is missing which to me shows that it isn't sending the data. Below I have the AJAX call I'm making: (function (jQ) { var inviteID = '00000000000'; jQ.ajax({ url: 'www.example.com/test.php', type: 'POST', dataType: 'json', cache: false, data: { classID: inviteID }, error: function (data, status, error) { jQ('.statusField').append('Failure: ' + data + status + error); }, success: function (data, status, error) { jQ('.statusField').append('Success: ' + data); } }); })(jQuery); And below I have the PHP script that's being used: <?php //first POST to grab token function runPost($classID) { $postdata = array( 'username' => 'username', 'password' => 'password' ); //open connection $ch = curl_init(); //set the url, POST data curl_setopt($ch, CURLOPT_URL, "https://www.example.com/login"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postdata)); curl_setopt($ch, CURLOPT_USERAGENT, 'example'); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //execute post $result = curl_exec($ch); //close connection curl_close($ch); list($message, $time, $token, $userID) = split(',', $result); list($one, $two, $three, $four, $five) = split('\"', $token); $four = json_encode($four); $four = str_replace('"','',$four); $secondaryPostData = array( 'token' => $four, 'data' => array( 'invitationID' => $classID )); //open connection $chu = curl_init(); //set the url, POST data curl_setopt($chu, CURLOPT_URL, "https://www.example.com/classID"); curl_setopt($chu, CURLOPT_POST, 1); curl_setopt($chu, CURLOPT_POSTFIELDS, json_encode($secondaryPostData)); curl_setopt($chu, CURLOPT_USERAGENT, 'example'); curl_setopt($chu, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($chu, CURLOPT_RETURNTRANSFER, 1); //execute post $secondResult = curl_exec($chu); //close connection curl_close($chu); return json_encode($secondResult); } //Grab classID from javascript echo runPost(trim($_POST['classID'])); ?> Again, this works fine in everything except IE. I've tried using just $.post and even XDomainRequest() and get the same result. The network console in IE shows that the Request body does have the classID in it, but I'm guessing it's just not sending the data to the PHP script. I don't know if I'm missing something that IE needs to send this to the PHP script but any help with this would be GREATLY appreciated.
  13. 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
  14. 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> ?>
  15. im having a simple html form that gets variables via 'POST' and passes them to simple.php, the simple.php file constructs a new link with the $_POST[] - and all i want to do is creating a simple iframe (this script is only for internal uses) underneath the form that will open the new link that was created within simple.php to clarify it a bit more here's form.html <form name="Students Management" action="http://myowntest.com/simple.php" method="post" accept-charset="utf-8"> <p> <label>First Name</label> <input type="text" value="" name="firstname" ></input> </p> <p> <label>Phone</label> <input type="text" value="" name="phone" ></input> </p> <p> <label>Last Name</label> <input type="text" value="" name="lastname" required="true"></input> </p> <p> <label>Company</label> <input type="text" value="" name="school" required="true"></input> </p> <p> <label>Email</label> <input type="text" value="" name="email" ></input> </p> <p> <label>Country</label> <input type="text" value="" name="age" ></input> </p> <p> <input type="submit" value="Submit" ></input> </p> </form> and here's simple.php <?php $newUrl = 'http://www.myothertestspace.com/simlpe2.php?name=' . $_POST['name'] . '&surname=' . $_POST['lastname'] . '&phone=' . $_POST['phone']; header(Location: $newUrl); ?> now, all i want is - after the user 'submits' the details on form.html , i'd like a new iframe will be shown up in the same page as the form that will show the user the contents of simple.php (which means - myothertestspace.com with the new parameters). thanks a lot!
  16. I am trying to learn how to program in PHP. For a long time i was using WAMP and my localhost. When i ran into trouble i searched the web, watched videos and eventually find a solution. Trying to upload my scripts into a shared hosting web server i had some difficulties in basic things, like using $_SESSION superglobal variable. What i want to do is to use a hidden field with a value inside a form, and after submitting the form, to compare the $_SESSION variable to the $_POST variable in order to check for CSRF. <?php //call all custom functions require_once('Custom_Functions/functions.php'); //session must be send before HTML headers secure_session_start(); ?> <!DOCTYPE html> <html lang="en"> <body> <?php if(isset($_POST['submit'])) { $postvalue = $_POST['input1']; $sessionvalue = $_SESSION['hashed_token']; echo '<br />==========================<br />'; echo '<br />AFTER PRESSING SUBMIT<br />'; echo '<br />==========================<br />'; echo 'Value of $_POST["hashed_token"] = '.$postvalue.'<br />'; echo 'Value of $_SESSION["hashed_token"] = '.$sessionvalue.'<br />'; } $hashed_token = hash('sha256', uniqid(mt_rand(), TRUE)); $_SESSION['hashed_token'] = $hashed_token; echo '<br />==========================<br />'; echo '<br />BEFORE PRESSING SUBMIT<br />'; echo '<br />==========================<br />'; echo '<br />Value of $_SESSION["hashed_token"] = '.$hashed_token.'<br />'; ?> <form action="" method="POST"> <input type="hidden" name="input1" value="<?php echo $hashed_token; ?>" /> <p><input type="submit" name="submit" /></p> </form> </body> </html> In this script i have 1 custom function: a) secure_session_start() function secure_session_start(){ //Set a custom session name $session_name = 'TESTSESSID'; ini_set('session.use_only_cookies', 1); ini_set('session.entropy_file', '/dev/urandom'); if (in_array('sha512', hash_algos())) { ini_set('session.hash_function', 'sha256'); } ini_set('session.use_trans_sid', 0); ini_set('session.hash_bits_per_character', 5); ini_set('session.cookie_secure', 1); $secure = TRUE; $httponly = TRUE; $cookieParams = session_get_cookie_params(); session_set_cookie_params($cookieParams['lifetime'], $cookieParams['path'], $cookieParams['domain'], $secure, $httponly); session_name($session_name); ini_set("session.save_path", "/home/SESSIONS"); session_start(); } The procedure goes as follows: FIRST COMMUNICATION WITH THE SERVER: The superglobal variable $_SESSION['hashed_token'] is assigned the random hash value, which is then passed to the hidden input field. I then echo it. RESULT: ========================== BEFORE PRESSING SUBMIT ========================== Value of $_SESSION["hashed_token"] = 93438a1b9b72085ce9430291acebdc4cfdee9d001b91a26207aebc22e04689fc SECOND COMMUNICATION WITH THE SERVER: The user press the submit button, the script then checks if the submit button is pressed, and gets in the if statement(because is TRUE). Then i collect the $_POST and $_SESSION values and echo them. New random hash is assigned to the $_SESSION superglobal variable. RESULT: ========================== AFTER PRESSING SUBMIT ========================== Value of $_POST["hashed_token"] = 93438a1b9b72085ce9430291acebdc4cfdee9d001b91a26207aebc22e04689fc Value of $_SESSION["hashed_token"] = 8f176aeb3a09a1b30e0ea862c78625d7c11743da933d366cface3fa238388e57 ========================== BEFORE PRESSING SUBMIT ========================== Value of $_SESSION["hashed_token"] = c3442382b146f03394ad86911018247c57fa19d4a653d0bf6bb9bc7506e88ca0 For me this is very weird. The random hash is assigned to the $_SESSION variable, but when i try to call it after the submit is pressed its giving me a complete different value. If i remove the function secure_session_start() and just use session_start() it works: RESULT (using session_start() ) ========================== AFTER PRESSING SUBMIT ========================== Value of $_POST["hashed_token"] = a5eaaaa38c428af623a599e664ea9c64a2ff0674e18e9250c54e52bbc586b614 Value of $_SESSION["hashed_token"] = a5eaaaa38c428af623a599e664ea9c64a2ff0674e18e9250c54e52bbc586b614 ========================== BEFORE PRESSING SUBMIT ========================== Value of $_SESSION["hashed_token"] = e2d4acc239a747217860d71a80553abd41142dbeb8f6fafab511caff8a081fc4 Any ideas why this is happening? The problem is inside the secure_session_start() function but i cant find out why. Also, when i use the secure_session_start() function and more specifically the ini_set("session.save_path", "/home/SESSIONS"); i am forcing the session to be stored inside the /home/SESSIONS folder. But when i only use the session_start() the session i still gets stored inside that path. I checked my .htaccess and there is nothing storing the sessions in that folder. Why is that? One last thing: When using FIREBUG-->Cookies is see 2 names: the custom one (TESTSESSID) and PHPSESSID(which is the default). Shouldnt i only see the custom session name only? Thanks in advance.
  17. 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.
×

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.