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

  1. I have the following array: $available_seasons = array ( 0 => array ( 'season_id' => 226, 'season_name' => '2022 - Season 1', 'season_price' => '25.99', 'season_start_date' => 'Jan. 1, 2022', 'season_end_date' => 'Mar. 31, 2022', 'prize' => 100, ), 1 => array ( 'season_id' => 227, 'season_name' => '2022 - Season 2', 'season_price' => '28.99', 'season_start_date' => 'Apr. 1, 2022', 'season_end_date' => 'Jun. 30, 2022', 'prize' => 100, ), 2 => array ( 'season_id' => 238, 'season_name' => '2022 - Season 3', 'season_price' => '40.99', 'season_start_date' => 'Jul. 1, 2022', 'season_end_date' => 'Sep. 30, 2022', 'prize' => 230, ), 3 => array ( 'season_id' => 239, 'season_name' => '2022 - Season 4', 'season_price' => '30.65', 'season_start_date' => 'Oct. 1, 2022', 'season_end_date' => 'Dec. 31, 2022', 'prize' => 300, ), ) I'm using the following loop to create the form: echo "<form name='seasonForm' method=\"post\" action='execute.php'>"; foreach ( $available_seasons as $k => $season ) { echo "<input name='choice' class='uk-checkbox' type='checkbox' value='{$season[ 'season_price' ]}' onchange='checkTotal()'/>"; } echo "<button type='submit'>Continue</button>"; I have the following JS to calculate the total price: function checkTotal() { document.seasonForm.total.value = \'\'; var sum = 0; for (i=0;i<document.seasonForm.choice.length;i++) { if (document.seasonForm.choice[i].checked) { sum = sum + (document.seasonForm.choice[i].value *1); } } document.seasonForm.total.value = "Total: $" + sum; } I am showing the total price to my users, before they click on submit. As it is, I am only able to able to get the value of one checkbox, which is season_price in my execute.php. What I need is to pass the all season_id and season_price values of the selected checkboxes to execute.php. I am not sure how to do this. Thank you for your help in advance.
  2. Hi everyone, I have a data analysis system which, however, takes too long to insert data into the db. Can you help me understand where I went wrong? thank you DB MYSQL: 1 analytics_number bigint(20) AUTO_INCREMENT 2 visitor_visitor_id varchar(50) utf8mb4_general_ci 3 visitor_session_id varchar(50) utf8mb4_general_ci 4 visitor_pageview_id varchar(50) utf8mb4_general_ci 5 visitor_visitor_sessions bigint(20) 6 visitor_visitor_session bigint(20) 7 visitor_visitor_pageviews bigint(20) 8 visitor_visitor_pageview bigint(20) 9 visitor_visitor_time bigint(20) 10 visitor_visitor_pages text utf8mb4_general_ci 11 visitor_visitor_first_page text utf8mb4_general_ci 12 visitor_visitor_last_page varchar(50) utf8mb4_general_ci 13 visitor_session_pageviews bigint(20) 14 visitor_session_pageview bigint(20) 15 visitor_session_time bigint(20) 16 visitor_session_pages text utf8mb4_general_ci 17 visitor_session_landingpage varchar(500) utf8mb4_general_ci 18 visitor_session_exitpage varchar(500) utf8mb4_general_ci 19 visitor_session_first_page varchar(50) utf8mb4_general_ci 20 visitor_session_last_page varchar(50) utf8mb4_general_ci 21 visitor_enter_timestamp varchar(50) utf8mb4_general_ci 22 visitor_enter_id varchar(50) utf8mb4_general_ci 23 visitor_enter_year int(11) 24 visitor_enter_month int(11) 25 visitor_enter_weekday int(11) 26 visitor_enter_day int(11) 27 visitor_enter_hour int(11) 28 visitor_enter_minute int(11) 29 visitor_leave_timestamp varchar(50) utf8mb4_general_ci 30 visitor_leave_id varchar(50) utf8mb4_general_ci 31 visitor_country varchar(50) utf8mb4_general_ci 32 visitor_country_code varchar(50) utf8mb4_general_ci 33 visitor_region varchar(100) utf8mb4_general_ci 34 visitor_region_code varchar(50) utf8mb4_general_ci 35 visitor_city varchar(100) utf8mb4_general_ci 36 visitor_zip int(11) 37 visitor_lat varchar(100) utf8mb4_general_ci 38 visitor_lon varchar(100) utf8mb4_general_ci 39 visitor_timezone varchar(100) utf8mb4_general_ci 40 visitor_isp varchar(100) utf8mb4_general_ci 41 visitor_language varchar(50) utf8mb4_general_ci 42 visitor_device varchar(100) utf8mb4_general_ci 43 visitor_device_brand varchar(100) utf8mb4_general_ci 44 visitor_device_model varchar(100) utf8mb4_general_ci 45 visitor_os varchar(100) utf8mb4_general_ci 46 visitor_os_version varchar(100) utf8mb4_general_ci 47 visitor_browser varchar(100) utf8mb4_general_ci 48 visitor_browser_version varchar(100) utf8mb4_general_ci 49 visitor_resolution varchar(50) utf8mb4_general_ci 50 visitor_viewport varchar(50) utf8mb4_general_ci 51 visitor_document varchar(50) utf8mb4_general_ci 52 visitor_referrer_url varchar(100) utf8mb4_general_ci 53 visitor_referrer_domain varchar(100) utf8mb4_general_ci 54 visitor_referrer_type varchar(100) utf8mb4_general_ci 55 visitor_referrer_name varchar(100) utf8mb4_general_ci 56 visitor_url varchar(500) utf8mb4_general_ci 57 visitor_domain varchar(100) utf8mb4_general_ci 58 visitor_page_path varchar(500) utf8mb4_general_ci 59 visitor_pageview_time bigint(20) 60 visitor_leave_url varchar(50) utf8mb4_general_ci 61 visitor_leave_domain varchar(100) utf8mb4_general_ci 62 visitor_leave_page varchar(50) utf8mb4_general_ci 63 visitor_leave_type varchar(100) utf8mb4_general_ci 64 visitor_leave_name varchar(100) utf8mb4_general_ci 65 visitor_pageview_update varchar(100) utf8mb4_general_ci --------------------------------------------------------------------------- CLASS PHP Analytics.php class analytics { public $search_sites; public $social_sites; private $_db; function __construct($db){ $this->search_sites = array("google" => "google", "goo" => "google", "bing" => "bing", "yahoo" => "yahoo", "baidu" => "baidu", "ask" => "ask", "aol" => "aol", "wow" => "wow", "webcrawler" => "webcrawler", "mywebsearch" => "mywebsearch", "infospace" => "infospace", "duckduckgo" => "duckduckgo", "yandex" => "yandex"); $this->social_sites = array("facebook" => "facebook", "fb" => "facebook", "twitter" => "twitter", "t.co" => "twitter", "youtube" => "youtube", "instagram" => "instagram", "snap" => "snapchat", "snapchat" => "snapchat", "reddit" => "reddit", "linkedin" => "linkedin", "xing" => "xing", "pinterest" => "pinterest", "tumblr" => "tumblr", "vine" => "vine", "meetup" => "meetup", "quora" => "quora"); $this->_db = $db; } public function get_analytics_enter($visitor_ip, $visitor_visitor_id, $visitor_session_id, $visitor_pageview_id, $visitor_referrer, $visitor_url, $visitor_resolution, $visitor_viewport, $visitor_document){ try{ $GET_array = array("visitor_ip" => $visitor_ip, "visitor_visitor_id" => $visitor_visitor_id, "visitor_session_id" => $visitor_session_id, "visitor_pageview_id" => $visitor_pageview_id, "visitor_referrer" => $visitor_referrer, "visitor_url" => $visitor_url, "visitor_resolution" => $visitor_resolution, "visitor_viewport" => $visitor_viewport, "visitor_document" => $visitor_document); require_once('analytics-db.php'); $analytics = array(); $query = "SELECT * FROM analytics WHERE visitor_visitor_id = '".$visitor_visitor_id."'"; $visitor_data = $this->_db->query($query)->fetchAll(); $visitor_ip_info = get_data_visitor($visitor_ip); $visitor_visitor_pageview = 0; $visitor_session_pageview = 0; $session_buffer = array(); $visitor_visitor_session = 0; $visitor_visitor_pages = array(); $visitor_session_pages = array(); $analytics["visitor_session_landingpage"] = NULL; $analytics["visitor_session_exitpage"] = NULL; foreach ($visitor_data as $visitor) { $visitor_visitor_pageview += 1; if (!in_array($visitor["visitor_page_path"], $visitor_visitor_pages)) { array_push($visitor_visitor_pages, $visitor["visitor_page_path"]); } if ($visitor["visitor_session_id"] == $visitor_session_id) { $visitor_session_pageview += 1; $analytics["visitor_session_exitpage"] = $visitor["visitor_page_path"]; if ($visitor_session_pageview == 1) { $analytics["visitor_session_landingpage"] = $visitor["visitor_page_path"]; } if (!in_array($visitor["visitor_page_path"],$visitor_session_pages)) { array_push($visitor_session_pages,$visitor["visitor_page_path"]); } } if (!in_array($visitor["visitor_session_id"],$session_buffer)) { array_push($session_buffer,$visitor["visitor_session_id"]); $visitor_visitor_session += 1; } } if (!in_array($visitor_session_id,$session_buffer)) { $visitor_visitor_session += 1; } foreach($GET_array as $key => $value) { if (in_array($key, $database_structure["analytics"])) { $analytics[$key] = $value; } } $analytics["visitor_visitor_sessions"] = $visitor_visitor_session; $analytics["visitor_visitor_session"] = $visitor_visitor_session; $analytics["visitor_visitor_pageviews"] = $visitor_visitor_pageview + 1; $analytics["visitor_visitor_pageview"] = $visitor_visitor_pageview + 1; $analytics["visitor_visitor_time"] = "0"; $analytics["visitor_session_pageviews"] = $visitor_session_pageview + 1; $analytics["visitor_session_pageview"] = $visitor_session_pageview + 1; $analytics["visitor_enter_timestamp"] = date("d.m.Y, H:i:s"); $analytics["visitor_enter_id"] = date("YmdHis"); $analytics["visitor_enter_year"] = date("Y"); $analytics["visitor_enter_month"] = date("m"); $analytics["visitor_enter_weekday"] = date("w"); $analytics["visitor_enter_day"] = date("d"); $analytics["visitor_enter_hour"] = date("H"); $analytics["visitor_enter_minute"] = date("i"); $analytics["visitor_leave_timestamp"] = date("d.m.Y, H:i:s"); $analytics["visitor_leave_id"] = date("YmdHis"); $analytics["visitor_pageview_time"] = "0"; $analytics["visitor_country"] = $visitor_ip_info["country"]; $analytics["visitor_country_code"] = $visitor_ip_info["countryCode"]; $analytics["visitor_region"] = $visitor_ip_info["regionName"]; $analytics["visitor_region_code"] = $visitor_ip_info["region"]; $analytics["visitor_city"] = $visitor_ip_info["city"]; $analytics["visitor_zip"] = $visitor_ip_info["zip"]; $analytics["visitor_lat"] = $visitor_ip_info["lat"]; $analytics["visitor_lon"] = $visitor_ip_info["lon"]; $analytics["visitor_timezone"] = $visitor_ip_info["timezone"]; $analytics["visitor_isp"] = $visitor_ip_info["isp"]; $analytics["visitor_language"] = substr($_SERVER["HTTP_ACCEPT_LANGUAGE"], 0, 2); $analytics["visitor_referrer_url"] = $visitor_referrer; $analytics["visitor_referrer_domain"] = $this->get_domain($visitor_referrer); $analytics["visitor_referrer_type"] = $this->visitor_referrer_type($this->get_domain($visitor_referrer)); $analytics["visitor_referrer_name"] = $this->visitor_referrer_name($this->get_domain($visitor_referrer)); $analytics["visitor_domain"] = $this->get_domain($visitor_url); if ($this->get_page($visitor_url) != "" && $this->get_page($visitor_url) != " " && $this->get_page($visitor_url) != "&nbsp;") { $analytics["visitor_page_path"] = $this->get_page($visitor_url); }else{ $analytics["visitor_page_path"] = "/"; } if (!in_array($analytics["visitor_page_path"], $visitor_visitor_pages)) { array_push($visitor_visitor_pages,$analytics["visitor_page_path"]); } if (!in_array($analytics["visitor_page_path"], $visitor_session_pages)) { array_push($visitor_session_pages,$analytics["visitor_page_path"]); } $analytics["visitor_visitor_pages"] = json_encode($visitor_visitor_pages); $analytics["visitor_session_pages"] = json_encode($visitor_session_pages); if ($analytics["visitor_visitor_pageview"] == 1) { $analytics["visitor_visitor_first_page"] = "true"; } if ($analytics["visitor_session_pageview"] == 1) { $analytics["visitor_session_first_page"] = "true"; } $sql_1_1 = "UPDATE analytics SET " . "visitor_visitor_last_page" . "='" . "" . "' WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "'"; $sql_1_2 = "UPDATE analytics SET " . "visitor_session_last_page" . "='" . "" . "' WHERE " . "visitor_session_id" . "='" . $visitor_session_id . "'"; $sql_1 = $sql_1_1."; ".$sql_1_2.";"; $this->_db->exec($sql_1); $analytics["visitor_visitor_last_page"] = "true"; $analytics["visitor_session_last_page"] = "true"; $analytics["visitor_device"] = visitor_device(); $analytics["visitor_device_brand"] = visitor_device(); $analytics["visitor_device_model"] = visitor_device(); $analytics["visitor_os"] = visitor_os(); $analytics["visitor_os_version"] = visitor_os(); $analytics["visitor_browser"] = visitor_browser(); $analytics["visitor_browser_version"] = visitor_browser(); $analytics["visitor_pageview_update"] = date("YmdHis"); $sql_2_1 = "INSERT INTO analytics ("; foreach ($analytics as $key => $value) {$sql_2_1 .= $key . ",";} $sql_2_1 = rtrim($sql_2_1,",") . ") VALUES ("; foreach ($analytics as $key => $value) {$sql_2_1 .= "'" . $value . "',";} $sql_2_1 = rtrim($sql_2_1,",") . ")"; $this->_db->exec($sql_2_1); $sql_2_2 = "UPDATE analytics SET " . "visitor_visitor_sessions" . "='" . $analytics["visitor_visitor_sessions"] . "' WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "'"; $sql_2_3 = "UPDATE analytics SET " . "visitor_visitor_pageviews" . "='" . $analytics["visitor_visitor_pageviews"] . "' WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "'"; $sql_2_4 = "UPDATE analytics SET " . "visitor_visitor_pages" . "='" . $analytics["visitor_visitor_pages"] . "' WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "'"; $sql_2_5 = "UPDATE analytics SET " . "visitor_session_pageviews" . "='" . $analytics["visitor_session_pageviews"] . "' WHERE " . "visitor_session_id" . "='" . $visitor_session_id."'"; $sql_2_6 = "UPDATE analytics SET " . "visitor_session_pages" . "='" . $analytics["visitor_session_pages"] . "' WHERE " . "visitor_session_id" . "='" . $visitor_session_id."'"; $sql_2_7 = "UPDATE analytics SET " . "visitor_session_landingpage" . "='" . $analytics["visitor_session_landingpage"] . "' WHERE " . "visitor_session_id" . "='" . $visitor_session_id."'"; $sql_2_8 = "UPDATE analytics SET " . "visitor_session_exitpage" . "='" . $analytics["visitor_session_exitpage"] . "' WHERE " . "visitor_session_id" . "='" . $visitor_session_id."'"; $sql_2 = $sql_2_2.";".$sql_2_3.";".$sql_2_4.";".$sql_2_5.";".$sql_2_6.";".$sql_2_7.";".$sql_2_8.";"; $this->_db->exec($sql_2); } catch(PDOException $e) { } } public function get_analytics_update($visitor_visitor_id, $visitor_session_id, $visitor_pageview_id, $visitor_pageview_time, $visitor_leave_url){ try{ $GET_array = array("visitor_visitor_id" => $visitor_visitor_id, "visitor_session_id" => $visitor_session_id, "visitor_pageview_id" => $visitor_pageview_id, "visitor_pageview_time" => $visitor_pageview_time, "visitor_leave_url" => $visitor_leave_url); require_once('analytics-db.php'); $query = "SELECT MAX(" . "visitor_visitor_time" . ") FROM analytics WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "' ORDER BY " . "visitor_enter_id" . " DESC LIMIT 1"; $visitor_visitor_time = $this->_db->query($query)->fetchColumn(); $query = "SELECT MAX(" . "visitor_session_time" . ") FROM analytics WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "' AND " . "visitor_session_id" . "='" . $visitor_session_id . "' ORDER BY " . "visitor_enter_id" . " DESC LIMIT 1"; $visitor_session_time = $this->_db->query($query)->fetchColumn(); $query = "SELECT MAX(" . "visitor_pageview_time" . ") FROM analytics WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "' AND " . "visitor_session_id" . "='" . $visitor_session_id . "' AND " . "visitor_pageview_id" . "='" . $visitor_pageview_id . "' ORDER BY " . "visitor_enter_id" . " DESC LIMIT 1"; $visitor_pageview_time = $this->_db->query($query)->fetchColumn(); $analytics = array(); foreach($GET_array as $key => $value) { if ($key != "visitor_visitor_id" && $key != "visitor_session_id" && $key != "visitor_pageview_id" && in_array($key, $database_structure["analytics"])) { if(is_array($value)) { $analytics[$key] = json_encode($value); }else{ $analytics[$key] = $value; } } } $analytics["visitor_leave_timestamp"] = date("d.m.Y, H:i:s"); $analytics["visitor_leave_id"] = date("YmdHis"); $analytics["visitor_visitor_time"] = $visitor_visitor_time + ($visitor_pageview_time - $visitor_pageview_time); $analytics["visitor_session_time"] = $visitor_session_time + ($visitor_pageview_time - $visitor_pageview_time); $analytics["visitor_pageview_update"] = date("YmdHis"); if (isset($visitor_leave_url)) { $analytics["visitor_leave_domain"] = $this->get_domain($visitor_leave_url); $analytics["visitor_leave_page"] = $this->get_page($visitor_leave_url); $analytics["visitor_leave_type"] = $this->visitor_leave_type($this->get_domain($visitor_leave_url)); $analytics["visitor_leave_name"] = $this->visitor_leave_name($this->get_domain($visitor_leave_url)); } $sql_1_1 = "UPDATE analytics SET "; foreach ($analytics as $key => $value) {$sql_1_1 .= $key . "='" . $value . "',";} $sql_1_1 = rtrim($sql_1_1,","); $sql_1_1 .= " WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "' AND " . "visitor_session_id" . "='" . $visitor_session_id . "' AND " . "visitor_pageview_id" . "='" . $visitor_pageview_id . "'"; $sql_1_2 = "UPDATE analytics SET " . "visitor_visitor_time" . "='" . $analytics["visitor_visitor_time"] . "' WHERE " . "visitor_visitor_id" . "='" . $visitor_visitor_id . "'"; $sql_1_3 = "UPDATE analytics SET " . "visitor_session_time" . "='" . $analytics["visitor_session_time"] . "' WHERE " . "visitor_session_id" . "='" . $visitor_session_id . "'"; $sql_1 = $sql_1_1."; ".$sql_1_2."; ".$sql_1_3.";"; $this->_db->exec($sql_1); } catch(PDOException $e) { } } function get_domain($url) { $pieces = parse_url($url); $domain = isset($pieces['host']) ? $pieces['host'] : ''; if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{0,63}\.[a-z\.]{1,6})$/i', $domain, $regs)) { return $regs['domain']; }else{ return false; } } function get_page($url) { return trim(str_replace($this->get_domain($url),"",str_replace("www.","",str_replace("http://","",str_replace("https://","",$url)))),"/"); } function visitor_referrer_type($referrer) { $search_sites = $this->search_sites; $social_sites = $this->social_sites; if ($referrer == "") { return "direct"; } $referrer = explode(".",$referrer); $referrer = strtolower($referrer[0]); if (array_key_exists($referrer,$search_sites)) { return "search"; }else if (array_key_exists($referrer,$social_sites)) { return "social"; }else { return "website"; } } function visitor_referrer_name($referrer) { $search_sites = $this->search_sites; $social_sites = $this->social_sites; if ($referrer == "") { return ""; } $referrer = explode(".",$referrer); $referrer = strtolower($referrer[0]); if (array_key_exists($referrer,$search_sites)) { return $search_sites[$referrer]; }else if (array_key_exists($referrer,$social_sites)) { return $social_sites[$referrer]; }else { return $referrer; } } function visitor_leave_type($leave_url) { $url_paz = $_SERVER['HTTP_HOST']; if ($leave_url == "") { return "unknown"; } if (strpos($leave_url, $url_paz) !== false) { return "internal"; }else { return "external"; } } function visitor_leave_name($leave_url) { if ($leave_url == "") { return ""; } $leave_url = $this->get_domain($leave_url); $leave_url = explode(".",$leave_url); $leave_url = strtolower($leave_url[0]); return $leave_url; } } ?> analytics-db.php <?php $database_structure = array(); $database_structure["analytics"] = array(); // Dataset IDs array_push($database_structure["analytics"],"visitor_visitor_id"); array_push($database_structure["analytics"],"visitor_session_id"); array_push($database_structure["analytics"],"visitor_pageview_id"); // Dataset Visitor Data array_push($database_structure["analytics"],"visitor_visitor_sessions"); array_push($database_structure["analytics"],"visitor_visitor_session"); array_push($database_structure["analytics"],"visitor_visitor_pageviews"); array_push($database_structure["analytics"],"visitor_visitor_pageview"); array_push($database_structure["analytics"],"visitor_visitor_time"); array_push($database_structure["analytics"],"visitor_visitor_pages"); array_push($database_structure["analytics"],"visitor_visitor_first_page"); array_push($database_structure["analytics"],"visitor_visitor_last_page"); // Dataset Session Data array_push($database_structure["analytics"],"visitor_session_pageviews"); array_push($database_structure["analytics"],"visitor_session_pageview"); array_push($database_structure["analytics"],"visitor_session_time"); array_push($database_structure["analytics"],"visitor_session_pages"); array_push($database_structure["analytics"],"visitor_session_landingpage"); array_push($database_structure["analytics"],"visitor_session_exitpage"); array_push($database_structure["analytics"],"visitor_session_first_page"); array_push($database_structure["analytics"],"visitor_session_last_page"); // Dataset Pageview Data // Dataset Enter Time array_push($database_structure["analytics"],"visitor_enter_timestamp"); array_push($database_structure["analytics"],"visitor_enter_id"); array_push($database_structure["analytics"],"visitor_enter_year"); array_push($database_structure["analytics"],"visitor_enter_month"); array_push($database_structure["analytics"],"visitor_enter_weekday"); array_push($database_structure["analytics"],"visitor_enter_day"); array_push($database_structure["analytics"],"visitor_enter_hour"); array_push($database_structure["analytics"],"visitor_enter_minute"); // Dataset Leave Time array_push($database_structure["analytics"],"visitor_leave_timestamp"); array_push($database_structure["analytics"],"visitor_leave_id"); // Dataset Geolocation array_push($database_structure["analytics"],"visitor_country"); array_push($database_structure["analytics"],"visitor_country_code"); array_push($database_structure["analytics"],"visitor_region"); array_push($database_structure["analytics"],"visitor_region_code"); array_push($database_structure["analytics"],"visitor_city"); array_push($database_structure["analytics"],"visitor_zip"); array_push($database_structure["analytics"],"visitor_lat"); array_push($database_structure["analytics"],"visitor_lon"); array_push($database_structure["analytics"],"visitor_timezone"); array_push($database_structure["analytics"],"visitor_isp"); array_push($database_structure["analytics"],"visitor_language"); // Dataset Technology array_push($database_structure["analytics"],"visitor_device"); array_push($database_structure["analytics"],"visitor_device_brand"); array_push($database_structure["analytics"],"visitor_device_model"); array_push($database_structure["analytics"],"visitor_os"); array_push($database_structure["analytics"],"visitor_os_version"); array_push($database_structure["analytics"],"visitor_browser"); array_push($database_structure["analytics"],"visitor_browser_version"); array_push($database_structure["analytics"],"visitor_resolution"); array_push($database_structure["analytics"],"visitor_viewport"); array_push($database_structure["analytics"],"visitor_document"); // Dataset Referrer array_push($database_structure["analytics"],"visitor_referrer_url"); array_push($database_structure["analytics"],"visitor_referrer_domain"); array_push($database_structure["analytics"],"visitor_referrer_type"); array_push($database_structure["analytics"],"visitor_referrer_name"); // Dataset Page array_push($database_structure["analytics"],"visitor_url"); array_push($database_structure["analytics"],"visitor_domain"); array_push($database_structure["analytics"],"visitor_page_path"); // Dataset Time array_push($database_structure["analytics"],"visitor_pageview_time"); // Dataset Leave array_push($database_structure["analytics"],"visitor_leave_url"); array_push($database_structure["analytics"],"visitor_leave_domain"); array_push($database_structure["analytics"],"visitor_leave_page"); array_push($database_structure["analytics"],"visitor_leave_type"); array_push($database_structure["analytics"],"visitor_leave_name"); // Dataset Update array_push($database_structure["analytics"],"visitor_pageview_update"); ?> analytics-enter.php <?php if(isset($_POST["visitor_ip"])){ $analytics->get_analytics_enter($_POST["visitor_ip"], $_POST["visitor_visitor_id"], $_POST["visitor_session_id"], $_POST["visitor_pageview_id"], $_POST["visitor_referrer"], $_POST["visitor_url"], $_POST["visitor_resolution"], $_POST["visitor_viewport"], $_POST["visitor_document"]); print "done"; }else{ print "error"; } ?> analytics-update.php <?php $analytics->get_analytics_update($_POST["visitor_visitor_id"], $_POST["visitor_session_id"], $_POST["visitor_pageview_id"], $_POST["visitor_pageview_time"], $_POST["visitor_leave_url"]); ?> JS FILE $(function(){ function create_cookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); }else { var expires = ""; } var host = window.location.hostname; var domain = host.substring(host.lastIndexOf(".", host.lastIndexOf(".") - 1) + 1); document.cookie = name+"="+value+expires+"; path=/; domain=." + domain; } function read_cookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca; while (c.charAt(0) == ' ') { c = c.substring(1,c.length); } if (c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length,c.length); } } return null; } function random_string(length, chars) { var result = ''; for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))]; return result; } function create_id() { var result = random_string(16, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); var date_time = new Date(); result += date_time.getFullYear(); result += date_time.getMonth(); result += date_time.getDate(); result += date_time.getHours(); result += date_time.getMinutes(); result += date_time.getSeconds(); return btoa(result); } function create_visitor_visitor_id() { if (visitor_visitor_id() == null) { create_cookie("visitor_id", create_id(), 3650) } } function visitor_visitor_id() { return read_cookie("visitor_id"); } function create_visitor_session_id() { if (visitor_session_id() == "") { sessionStorage.setItem("visitor_session_id", create_id()); } } function visitor_session_id() { return sessionStorage.getItem("visitor_session_id") == null ? "" : sessionStorage.getItem("visitor_session_id"); } function get_ip() { return $.getJSON("https://api.ipify.org?format=jsonp&callback=?").then(function(data){ return { visitor_ip: data.ip } }); } if (new URL(window.location.href).searchParams.get("analytics") != "true") { create_visitor_visitor_id(); create_visitor_session_id(); var analytics_script_location = "/analytics/controllers/"; var screen_width = screen.width; var screen_height = screen.height; var viewport_width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var viewport_height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; var document_width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var document_height = document.documentElement.scrollHeight; var visitor_ip; get_ip().then(function(returndata){ visitor_ip = returndata.visitor_ip}); var visitor_visitor_id = visitor_visitor_id(); var visitor_session_id = visitor_session_id(); var visitor_pageview_id = create_id(); var visitor_enter_time = new Date(); var visitor_referrer = document.referrer; var visitor_url = window.location.href; var visitor_resolution = screen_width + "x" + screen_height; var visitor_viewport = viewport_width + "x" + viewport_height; var visitor_document = document_width + "x" + document_height; var visitor_leave_url = "NULL"; var current_time = 0; var scroll_sum = 0; var scroll_count = 0; var visitor_enter_sent = false; var visitor_leave_sent = false; var current_viewport_width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var current_viewport_height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; var current_document_width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var current_document_height = document.documentElement.scrollHeight; var current_viewport = current_viewport_width + "x" + current_viewport_height; var previous_viewport = current_viewport_width + "x" + current_viewport_height; var current_document = current_document_width + "x" + current_document_height; var previous_document = current_document_width + "x" + current_document_height; function track_a_href(event) { visitor_leave_url = event.target.href; analytics_visitor_leave(); } function analytics_visitor_enter() { if (visitor_enter_sent == false) { $.ajax({ type: "POST", url: analytics_script_location + "analytics-enter.php", data: { visitor_ip: visitor_ip, visitor_visitor_id: visitor_visitor_id, visitor_session_id: visitor_session_id, visitor_pageview_id: visitor_pageview_id, visitor_referrer: visitor_referrer, visitor_url: visitor_url, visitor_resolution: visitor_resolution, visitor_viewport: visitor_viewport, visitor_document: visitor_document }, success: function(data){ if(data == "done"){ visitor_enter_sent = true; }else{ visitor_enter_sent = false; } } }); } } function analytics_visitor_update() { var visitor_pageview_time = Math.round(((new Date() - visitor_enter_time)/1000)%60); $.ajax({ type: "POST", url: analytics_script_location + "analytics-update.php", data: { visitor_visitor_id: visitor_visitor_id, visitor_session_id: visitor_session_id, visitor_pageview_id: visitor_pageview_id, visitor_pageview_time: visitor_pageview_time, visitor_leave_url: visitor_leave_url } }); } window.setInterval(function() { if(visitor_enter_sent == true){ analytics_visitor_update(); }else{ analytics_visitor_enter(); } }, 15000); function analytics_visitor_leave() { if (visitor_leave_sent == false) { analytics_visitor_update(); visitor_leave_delay(250); visitor_leave_sent = true; } } function visitor_leave_delay(time) { var start = +new Date; while ((+new Date - start) < time); } $(window).load(function() { analytics_visitor_enter(); }); $(window).on('pagehide', function () { analytics_visitor_leave(); }); $(window).on('beforeunload', function () { analytics_visitor_leave(); }); $(window).unload( function() { analytics_visitor_leave(); }); } });
  3. 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 ); }
  4. 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.
  5. 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
  6. 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. 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
  8. 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
  9. 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.
  10. 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.
  11. 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.
  12. 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.
  13. 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> ?>
  14. 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.
  15. 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.
  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. 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?
  18. 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!
  19. Hi, Im making a basic encryption program and have the encryption side working, but want to add in the feature to "decrypt" the encoded message if need be. Im using the POST method so that my program outputs to the same page that the form is on. I have tried the following : if ( isset($_POST["decrypt"]) ) { echo $_SESSION[$old_ascii]; } if ( $key < 1 || $key > 125 ) { echo "Please enter a key between 1 and 125</br>"; } else { foreach ( $userText as $old_ascii ) { echo $new_ascii = chr(imp_circular_position(32,126, ord( $old_ascii ), $key)); $_SESSION[$old_ascii] .= $old_ascii; } All i really want to do is store the users first entered text and relay that when the decrypt button is pressed the code for that is : <div id="buttons"> <input type="submit" value="Encrypt" name="Encrypt" /> <input name="decrypt" type="submit" value="De-crypt" /> </div> if( isset($_POST["userText"]) && $_POST["key"] ) { if( empty($_POST["userText"]) || empty($_POST["key"]) ) { die("Please enter a key between 1 and 125 and enter some secret message for me to encrypt!</br>"); } $userText = $_POST["userText"]; $key = $_POST["key"]; } If anyone could help with this id really appreciate it , so all i want to do is store the text first entered in a variable if I was using GET then it would be easy but this is my first time outputting text to the same page as the form and am a little lost! Thanks!
  20. Ok if have some code that i am trying to add to. <form action="#" method="post" enctype="multipart/form-data"> <input type="text" name="search"/> <input type="submit" name="search1"/> </form> <?php if(isset($_POST['search1'])){ $search=mysql_real_escape_string($_POST['search']); } include 'connect.php'; if(isset($_POST['search1'])){ $query=mysql_query("SELECT * FROM media WHERE extra_cred LIKE '%".$search."%' OR artist_id LIKE '%".$search."%' OR title LIKE '%".$search."%' OR content LIKE '%".$search."%' OR detail LIKE '%".$search."%' OR tags LIKE '%".$search."%' OR user LIKE '%".$search."%' OR type LIKE '%".$search."%' ") ?> What I would like to do is also search another table within that database by the name of artists with the same POST data. Anyone know what to do? I've been at this for a while.
  21. <?php while($row=mysql_fetch_array($data1)) { echo "<li><input type='checkbox' name='listitem[]' value='".$row['cat']."'>".$row['cat']; } echo $row[1]; ?> <br/> <input type="submit" value="send" /> <?php foreach($_POST['listitem'] as $value) { ?> <a href="cloud.php?q=<?php echo $value; ?>"></a> <?php //echo "<a href=cloud.php?p=+'".$value."' target='_blank'></a>"; echo 'Checked: '.$value.''; } ?> i need to send $value parameter to another page.. the above is my code snippet. thank you in advance
  22. Hello, Is there any way to -remotely- insert a post to a custom wordpress URL? Assuming I have a network of 5 websites and i would like to update all of them through some form i'll build (may say - a mini CMS maybe). Site 1 - [Form for content] [submit button] Site 2 - [Form2 for content] [[submit button]] Site 3 - [Form3 for content] [submit button] ... and so on. And simply everytime i'll pust the submit button the Form3 content will go to a specific wordpress website, and same about Form2 and Form1. Thanks.
  23. Hello everyone, I have "Posts" table in my model. "Posts" table have these columns : ID , title , image , category , description , body , author , created_date. I want to extend my "Posts" table by adding a column "tags". I want my php website to compare one post with others by "tags". Is it this option good? or I must make a different table with foreign keys and tags. Please anwser me if you can the mySQL queries and the right database Model. Thenks
  24. I've been trying to work on a form in PHP. I've got it all set up and submitting but the only problem is that I try to display the data back on the page for testing purposes but every time I hit submit, it empties the form with no results. I've written my code as follows: <!DOCTYPE html> <head> <link rel="stylesheet" type="text/css" href="styling.css"> </head> <body> <form action="registerplayer.php" action="POST"> <p>First Name:<input type='text' name='firstName'></p> <p>Last Name:<input type='text' name='lastName'></p> <p>Username:<input type='text' name='username'></p> <p>Password:<input type='text' name='password'></p> <p><input type='submit' value='Submit'></p> </form> <?php if(isset($_POST["firttName"]) && isset($_POST["lastName"]) && isset($_POST["username"]) && isset($_POST["password"])) { $firstname = $_POST["firstName"]; $lastname = $_POST["lastName"]; $username = $_POST["username"]; $password = $_POST["password"]; echo "<p>Name: " . $firstname . " " . $lastname . "\nUsername: " . $username . "\nPassword: " . $password . "</p>"; } ?> </body></html> Anyone know what I'm not seeing here? I've been working on this for a while now.
  25. Hi, I'm after a song search request script to be made for my website below is some info and bullet points of what I would like the script to have. > Search box and the php script will read a .csv file and show matching data > Search results to show up in table column 1 radio button, column 2 Artists, column 3 tracks, > Above results search box below search results a contact form that will email song request and Name (mandatory), email (mandatory) Dedicate (optional) comment (optional) to my own email address > Alphabetical listing (ie clicking A will show all artists beginning with A) Above search box I do have some other ideas - email me and I'll give you my Skype ID so we can talk more
×
×
  • 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.