Jump to content

Search the Community

Showing results for 'detecting mobile device'.

  • 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. the code for any page should be laid out in this general order - initialization post method form processing get method business logic - get/produce data needed to display the page html document the post method form processing should - detect if a post method form was submitted keep all the input data in an array variable, then operate on elements in this array variable throughout the rest of the code trim all the inputs at once. after you do item #2 on this list, you can accomplish this with one line of code validate all the inputs, storing user/validation errors in an array using the field name as the array index after the end of all the validation logic, if the array holding the errors is empty, use the form data if an insert or update query can result in duplicate data, detect this in the error handling for the database query, and setup a message for the user telling them what was wrong with the data that they submitted after the end of the form processing logic, if there are no user/validation errors, perform a redirect to the exact same url of the current page to cause a get request for the page. to display a one-time success message, store it in a session variable, then test, display, and clear the session variable at the appropriate location in the html document. if there are errors at item #5 or #7 on this list, the code will continue on to display the html document, redisplay the form, where you should populate the form field values/selects/checkboxes with any existing values so that the user doesn't need to keep reentering/selecting/checking data over and over. you should get your code to fully work first with one form field, then one field of each type, before you worry about all the code needed for all the rest of the fields. you can use the following to display what post data is being submitted to your code - echo '<pre>'; print_r($_POST); echo '</pre>'; the posted code contains a php syntax error on line #13. to get php to display syntax errors, you must set php's error_reporting to E_ALL and display_errors to ON, in the php.ini on your development system (putting these settings into your code won't work for php syntax errors since your code never runs to change the settings.) stop and start your web server to get any changes made to the php.ini to take effect and confirm that the settings actually got changed by using a phpinfo() statement in a .php script file. you should also validate any resulting web page at validator.w3.org to help make sure the markup is valid and you should only write markup that is necessary.
  2. Hey guys, very simple script to register a user. Not sure why but the query (line 69) isn't adding the data to the database? Show errors are on, but shows none and none in my logs. Anyone have an idea? Thanks! <?php include('config/db.php'); require_once './lib/vendor/autoload.php'; global $success_msg, $email_exist, $f_NameErr, $l_NameErr, $_emailErr, $_mobileErr, $_passwordErr; global $fNameEmptyErr, $lNameEmptyErr, $emailEmptyErr, $mobileEmptyErr, $passwordEmptyErr, $email_verify_err, $email_verify_success; $_first_name = $_last_name = $_email = $_mobile_number = $_password = ""; if(isset($_POST["submit"])) { $firstname = $_POST["firstname"]; $lastname = $_POST["lastname"]; $email = $_POST["email"]; $mobilenumber = $_POST["mobilenumber"]; $password = $_POST["password"]; $email_check_query = mysqli_query($connection, "SELECT * FROM users WHERE email_address = '{$email}' "); $rowCount = mysqli_num_rows($email_check_query); if(!empty($firstname) && !empty($lastname) && !empty($email) && !empty($mobilenumber) && !empty($password)){ if($rowCount > 0) { $email_exist = ' <div class="alert alert-danger" role="alert"> User with email already exist! </div> '; } else { $_first_name = mysqli_real_escape_string($connection, $firstname); $_last_name = mysqli_real_escape_string($connection, $lastname); $_email = mysqli_real_escape_string($connection, $email); $_mobile_number = mysqli_real_escape_string($connection, $mobilenumber); $_password = mysqli_real_escape_string($connection, $password); if(!preg_match("/^[a-zA-Z ]*$/", $_first_name)) { $f_NameErr = '<div class="alert alert-danger"> Only letters and white space allowed. </div>'; } if(!preg_match("/^[a-zA-Z ]*$/", $_last_name)) { $l_NameErr = '<div class="alert alert-danger"> Only letters and white space allowed. </div>'; } if(!filter_var($_email, FILTER_VALIDATE_EMAIL)) { $_emailErr = '<div class="alert alert-danger"> Email format is invalid. </div>'; } if(!preg_match("/^[0-9]{11}+$/", $_mobile_number)) { $_mobileErr = '<div class="alert alert-danger"> Only 11-digit mobile numbers allowed. </div>'; } if(!preg_match("/^(?=.*\d)(?=.*[@#\-_$%^&+=§!\?])(?=.*[a-z])(?=.*[A-Z])[0-9A-Za-z@#\-_$%^&+=§!\?]{6,20}$/", $_password)) { $_passwordErr = '<div class="alert alert-danger"> Password should be between 6 to 20 charcters long, contains atleast one special chacter, lowercase, uppercase and a digit. </div>'; } if((preg_match("/^[a-zA-Z ]*$/", $_first_name)) && (preg_match("/^[a-zA-Z ]*$/", $_last_name)) && (filter_var($_email, FILTER_VALIDATE_EMAIL)) && (preg_match("/^[0-9]{10}+$/", $_mobile_number)) && (preg_match("/^(?=.*\d)(?=.*[@#\-_$%^&+=§!\?])(?=.*[a-z])(?=.*[A-Z])[0-9A-Za-z@#\-_$%^&+=§!\?]{8,20}$/", $_password))){ $token = md5(rand().time()); $password_hash = password_hash($password, PASSWORD_BCRYPT); $sql = "INSERT INTO users (first_name, last_name, email_address, mobile_number, password, token, is_active, date_time) VALUES ('{$firstname}', '{$lastname}', '{$email}', '{$mobilenumber}', '{$password_hash}', '{$token}', '0', now())"; $sqlQuery = mysqli_query($connection, $sql); if(!$sqlQuery){ die("MySQL query failed!" . mysqli_error($connection)); } if($sqlQuery) { $msg = 'Click on the activation link to verify your email. <br><br> <a href="*****/user_verificaiton.php?token='.$token.'"> Click here to verify email</a> '; $transport = (new Swift_SmtpTransport('mail.****.com', 587, 'tls')) ->setUsername('*****') ->setPassword('*****'); $mailer = new Swift_Mailer($transport); $message = (new Swift_Message('Please Verify Email Address!')) ->setFrom([$email => $firstname . ' ' . $lastname]) ->setTo($email) ->addPart($msg, "text/html") ->setBody('Hello! User'); $result = $mailer->send($message); if(!$result){ $email_verify_err = '<div class="alert alert-danger"> Verification email coud not be sent! </div>'; } else { $email_verify_success = '<div class="alert alert-success"> Verification email has been sent! </div>'; } } } } } else { if(empty($firstname)){ $fNameEmptyErr = '<div class="alert alert-danger"> First name can not be blank. </div>'; } if(empty($lastname)){ $lNameEmptyErr = '<div class="alert alert-danger"> Last name can not be blank. </div>'; } if(empty($email)){ $emailEmptyErr = '<div class="alert alert-danger"> Email can not be blank. </div>'; } if(empty($mobilenumber)){ $mobileEmptyErr = '<div class="alert alert-danger"> Mobile number can not be blank. </div>'; } if(empty($password)){ $passwordEmptyErr = '<div class="alert alert-danger"> Password can not be blank. </div>'; } } } ?>
  3. Mobile Application is the process of developing software applications that run on mobile devices or tablets, commonly for OS and iOS versions, which are easily downloaded from the play store or app store, and at any time can be uninstalled. All the mobile applications are easily accessible from web browsers too. Whether you are looking for a mobile application for android or iOS, a smartphone or a tablet, The professional app developers at Byteteck Consulting know the game. We have agile solutions for each project that we deliver. The need for mobile application services is increasing daily due to the usage of digital devices. The application development services are used in various industries like retail, telecommunications and e-commerce to insurance, healthcare and government organizations. From idea to concept to delivery and during the ongoing project, customer support. What Languages Does Android Mobile Application Use? 70 percent of smartphones operating are for Android, and the Google Play Store has more infrequent limitations than the Apple App Store. The android mobile application is usually written in Java, the de facto programming language. But Java is still considered as the But now, modern Android developers have more opportunities at their fingertips. Now application developers have the liberty to build native and cross-platform Android applications with the preferences of C# and C++. Now the developers have comprehensive options in terms of programming language. They don't just have to stick to the Java programming language. Benefits of Android Mobile Application Do you intend to have your mobile application for your business and are confused about what platform to use? There are several great benefits to choosing an android application for your business. Listing some few below: ● Readily Customizable Android apps constantly get updated with new features & tools. ● Fast Development Cycle The most accessible and versatile platform in the market. ● User-Friendly Even a non-tech person can easily use android apps. ● Safe and Secure The user's data is highly secured. ● Cross-Platform The application can be easily achieved for OS and iOS platforms. Why Choose ByteTeck Consulting For Android Development Services? ByteTeck Consulting has been providing Android application development services in North America for over 15+ years. Since then, our primary focus has been to build reliable, fast, smooth, and eye-catching mobile applications for android. It is because we understand our client's project requirements, all the nitty gritty to deliver precisely the same they desire, no matter how small or tricky it can be.
  4. I have some very simple code in a PHP web application that is something like this: <select name="my_select" id="my_select" value=""> <option value=""></option> <option value="1">Pass</option> <option value="0">Fail</option> </select> if (empty($_POST['myselect'])) { // if no select value is chosen, field value = current value $field_value = $_REQUEST['field_value']; } else { // else set field value to select value $field_value = $_POST['select_value']; } $sql = "update my table set field_value = :field_value"; If the user chooses a value from the select list, that value is used to update a table. If the select value is empty, the field value stays as is. A button triggers the update query. This has been working fine until today. Now, if the user selects a value, the field is updated to 1 / Pass. But if the button is clicked again and no value is chosen, the field is automatically updated to the opposite value, 0 / Fail. I can't figure out why this is suddenly happening after it worked correctly for so long. Any input you may have would be appreciated.
  5. First you are going to have to bear some criticism of your code DO NOT connect to the server every time you call a function. Connect once at the top of index.php an pass the connection in the function calls. Connections are slow and you will overburden your server with connections You don't need 3 function calls to get the status totals - one will suffice You don't execute() after query(), execute() is for prepared statements. Don't put a closing ?> at end of included php files Lecture over, here's how I would do it (skeleton) index.php <?php require 'SqlConn.php'; $SC = 0; $FC = 0; // get status counts and store counts in an array $statusCounts = JC($conn); // pass $conn to function // output status counts echo "<h2>Completed : {$statusCounts['Completed']}</h2>"; echo "<h2>In-Progress : {$statusCounts['In-Progress']}</h2>"; echo "<h2>On-Hold : {$statusCounts['ON_HOLD']}</h2>"; // check critical systems CriticalSystem( $SC, $FC ); // output system success counts countupdown($SC, $FC); ?> functions.php <?php function JC($conn) // pass $conn to function { $sql = "Select Status , Count(Status) as total from EXCELMACRO...Jobs$ group by Status "; $stmt = $conn->query($sql); $resultCompleted = $stmt->fetchAll(); return array_column($resultCompleted, 'total', 'Status'); // return array of totals bt status } function CriticalSystem( &$SC, &$FC ) // pass count variables by reference { //array for critical devices $systems = array( array('ip' => '192.168.9.254', 'name' => 'Tech Swtich'), array('ip' => '192.168.9.205', 'name' => 'Printer'), array('ip' => '192.168.9.200', 'name' => 'Sales Printer'), array('ip' => '192.168.9.201', 'name' => 'Admin Printer'), array('ip' => '192.168.9.1', 'name' => 'KVM'), array('ip' => '192.168.9.2', 'name' => 'Office Data 24 Port'), array('ip' => '192.168.9.3', 'name' => 'Office Data 48 Port'), array('ip' => '192.168.9.4', 'name' => 'Office Voice 48 Port'), array('ip' => '192.168.9.7', 'name' => 'Warehouse Switch'), array('ip' => '192.168.9.13', 'name' => 'Foundry Canteen Switch'), ); //Result to search for to give success result $good = "Received = 1"; //troubleshooting to see if being re-freshed //echo "<h1>Site Status ".date("h:i:s")."</h1>"; echo "<table border='0' class='table'>"; // foreach loop to ping IP and check if alive or dead & dispaly result foreach ($systems as $ip) { unset($result); $successValue = "DOWN"; exec("ping -n 1 $ip[ip]", $result); foreach($result as $line) { if (strpos($line,$good) == TRUE){ $successValue = "UP"; } } echo "<tbody> <tr> <td>IP Address: {$ip['ip']}</td> <td>Unit Name: {$ip['name']}</td> </tr> <tr> <td>Status is: $successValue</td> <td>" . ($successValue == "UP" ? "<img src='/Images/GTick.jpg'>" ."<span style='color:#000000'>". $SC++ ."</span>" : "<img src='/Images/RTick.jpg'>" . "<span style='color:#000000'>".$FC++ ."</span>"). "</td> </tr> </tbody> "; } echo"</table>"; $FC = count($systems) - $SC; } function countupdown($countup, $countdown) // pass counts to function { echo "<center>"; echo "<br></br>"; echo "<img src='/Images/GTick.jpg'>". " " . "Systems Online = ".$countup; echo "<br></br>"; echo "<img src='/Images/RTick.jpg'>". " ". "Systems Offline = ".$countdown; echo "</center>"; }
  6. Hi, As promised here is the code this is my functions.php: <?php //$GLOBAL Variables //$GLOBALS['SC'] = 0; //$GLOBALS['FC'] = 0; //$GLOBALS['countup'] = 0; //$GLOBALS['countdown'] = 0; function completedJC(){ //completed call count include 'SqlConn.php'; $sql = "Select Count(Status) from EXCELMACRO...Jobs$ where Status = 'Completed'"; $stmt = $conn->query($sql); $stmt->execute(); $resultCompleted = $stmt->fetchColumn(); echo $resultCompleted; } function inprogressJC(){ //In-progress call count include 'SqlConn.php'; $sql = "Select Count(Status) from EXCELMACRO...Jobs$ where Status = 'In-Progress'"; $stmt = $conn->query($sql); $stmt->execute(); $resultInprogress = $stmt->fetchColumn(); echo $resultInprogress; } function OnHoldJC(){ //On-hold call count include 'SqlConn.php'; $sql = "Select Count(Status) from EXCELMACRO...Jobs$ where Status = 'ON-HOLD'"; $stmt = $conn->query($sql); $stmt->execute(); $resultOnHold = $stmt->fetchColumn(); echo $resultOnHold; } function CriticalSystem(){ //array for critical devices //Black #000000 //White #FFFFFF $SC = 0; $FC = 0; $countup = 0; $countdown = 0; $systems = array( array('ip' => '192.168.9.254', 'name' => 'Tech Swtich'), array('ip' => '192.168.9.205', 'name' => 'Printer'), array('ip' => '192.168.9.200', 'name' => 'Sales Printer'), array('ip' => '192.168.9.201', 'name' => 'Admin Printer'), array('ip' => '192.168.9.1', 'name' => 'KVM'), array('ip' => '192.168.9.2', 'name' => 'Office Data 24 Port'), array('ip' => '192.168.9.3', 'name' => 'Office Data 48 Port'), array('ip' => '192.168.9.4', 'name' => 'Office Voice 48 Port'), array('ip' => '192.168.9.7', 'name' => 'Warehouse Switch'), array('ip' => '192.168.9.13', 'name' => 'Foundry Canteen Switch'), ); //Result to search for to give success result $good = "Received = 1"; $successValue; //troubleshooting to see if being re-freshed //echo "<h1>Site Status ".date("h:i:s")."</h1>"; echo "<table border='0' class='table'>"; // foreach loop to ping IP and check if alive or dead & dispaly result foreach ($systems as $ip) { unset($result); $successValue = "DOWN"; exec("ping -n 1 $ip[ip]", $result); foreach($result as $line) { if (strpos($line,$good) == TRUE){ $successValue = "UP"; //$count = $successValue; } } echo "<tbody> <tr> <td>IP Address: {$ip['ip']}</td> <td>Unit Name: {$ip['name']}</td> </tr> <tr> <td>Status is: $successValue</td> <td>" . ($successValue == "UP" ? "<img src='/Images/GTick.jpg'>" ."<span style='color:#000000'>". $SC++ ."</span>" : "<img src='/Images/RTick.jpg'>" . "<span style='color:#000000'>".$FC++ ."</span>"). "</td> </tr> </tbody> "; } echo"</table>"; //debug dispaly full result of ping request //var_dump($result); $countup = array($SC); $countdown = array($FC); print_r($countup); //Print_r($countdown); } function countupdown(){ global $SC, $FC, $countup, $countdown; echo "<center>"; echo "<br></br>"; echo "<img src='/Images/GTick.jpg'>". " " . "Systems Online = ".$countup; echo "<br></br>"; echo "<img src='/Images/RTick.jpg'>". " ". "Systems Offline = ".$countdown; echo "</center>"; print_r($countup); } ?> Here is my index.php <!doctype html> <html lang="en"> <?php //Function Scripts //SqlConn include 'SqlConn.php'; //Completed Job Count include 'Functions.php'; ?> <head> <title>Support Desk</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content="James Stirling"> <meta name="generator" content="Hugo 0.98.0"> <meta http-equiv="refresh" content="5" <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"> <link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png"> <link rel="manifest" href="favicon/site.webmanifest"> <link rel="mask-icon" href="favicon/safari-pinned-tab.svg" color="#5bbad5"> <meta name="msapplication-TileColor" content="#da532c"> <meta name="theme-color" content="#ffffff"> <link rel="canonical" href="https://getbootstrap.com/docs/5.2/examples/features/"> <link href="/docs/5.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous"> </head> <!-- <title>Support Desk</title> --> <body> <style> .btn-primary { --bs-btn-color: #fff; --bs-btn-bg: #007A53; --bs-btn-focus-shadow-rgb: 49, 132, 253; --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125) } .b-divider { height: 3rem; background-color: rgba(0, 0, 0, .1); border: solid rgba(0, 0, 0, .15); border-width: 1px 0; box-shadow: inset 0 .5em 1.5em rgba(0, 0, 0, .1), inset 0 .125em .5em rgba(0, 0, 0, .15); } </style> <main> <!-- Calls Logged --> <div class="container px-4 py-5" id="hanging-icons"> <center> <h2 class="pb-2 border-bottom">Hargreaves Foundry & Drainage Critical System Status Page</h2> </center> </div> <div class="container px-4 py-5" id="hanging-icons"> <h2 class="pb-2 border-bottom">Open Calls: View all status of IT faults</h2> <div class="row g-4 py-5 row-cols-1 row-cols-lg-3"> <div class="col d-flex align-items-start"> <div class="icon-square bg-light text-dark d-inline-flex align-items-center justify-content-center fs-4 flex-shrink-0 me-3"> </div> <div> <h2>Completed: (<?php completedJC();?>)</h2> <p>Number of all calls that have been completed for each department and staff member.</p> </div> </div> <div class="col d-flex align-items-start"> <div class="icon-square bg-light text-dark d-inline-flex align-items-center justify-content-center fs-4 flex-shrink-0 me-3"> </div> <div> <h2>In-Progress: (<?php inprogressJC();?>)</h2> <p>Number of open calls and the progress of the call for a department or staff member.</p> </div> </div> <div class="col d-flex align-items-start"> <div class="icon-square bg-light text-dark d-inline-flex align-items-center justify-content-center fs-4 flex-shrink-0 me-3"> </div> <div> <h2>ON-HOLD: (<?php OnHoldJC();?>)</h2> <p>Number of calls placed ON-HOLD for what ever reason or awaiting input from a third party.</p> </div> </div> </div> </div> <div class="b-divider"></div> <!-- Critical Systems --> <div class="container px-4 py-5" id="hanging-icons"> <h2 class="pb-2 border-bottom">Critical Systems Online\Offline Count</h2> <?php countupdown(); ?> </div> <div class="b-divider"></div> <!-- Critical Systems --> <div class="container px-4 py-5" id="hanging-icons"> <h2 class="pb-2 border-bottom">Critical Systems Ping Check</h2> <?php CriticalSystem(); ?> </div> </main> <div class="b-divider"></div> <script src="/docs/5.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script> </body> <footer class="py-3 my-4"> <ul class="nav justify-content-center border-bottom pb-3 mb-3"> </ul> <p class="text-center text-muted">© 2022 Hargreaves Foundry & Drainage, Inc</p> <center> <img src="docs/5.2/images/image1.png" style="width:40px;height:40px;margin-top:20px" /> </center> </footer> </html> Any question please ask. Thanks James
  7. I have not done any php coding for some time and I can't figure out why this coding is not working? I am trying to create a form for my club so that members can fill in a form online. I have written a form which is in html which using POST collects the data from the form and should INSERT it into the database. Here is the html file: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="generator" content="RSD 5.0.3519"> <title>Senior Form</title> <link rel="stylesheet" href="css/bootstrap4.min.css"> <link rel="stylesheet" href="css/wireframe-theme.min.css"> <script>document.createElement( "picture" );</script> <script class="picturefill" async="async" src="js/picturefill.min.js"></script> <link rel="stylesheet" href="css/main.css"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Averia+Sans+Libre:400,b%7CRoboto:400,900,b"> </head> <body class="body-3"><div class="responsive-picture picture-1 align-content-md-center"> <picture> <img alt="Placeholder Picture" width="1200" height="300" src="./images/1066MFC%20Banner.jpg" loading="lazy"> </picture> </div> <nav class="container-grid navbar navbar-expand-lg navbar-dark bg-dark"> <h3 class="navbar-brand">MENU</h3><button type="button" class="btn navbar-toggler navbar-toggler-icon button Dropdown-toggle" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-label="Toggle navigation"></button> <div class="container-grid collapse navbar-collapse" id="navbarNavDropdown"> <ul class="list-container navbar-nav"> <li class="list-item-container nav-item"> <a class="link-text nav-link" href="index.html" title="">HOME</a> </li> <li class="list-item-container nav-item"> <a class="link-text nav-link" href="about.html" title="">ABOUT</a> </li> <li class="list-item-container nav-item dropdown"> <a class="link-text nav-link dropdown-toggle" href="members.html#navbarNavDropdown" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">MEMBERS</a> <div class="container-grid dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> <a class="link-text dropdown-item" href="members.html" title="">Members</a> <a class="link-text dropdown-item" href="aerodrome.html" title="PEBSHAM AERODROME">Pebsham Aerodrome</a> <a class="link-text dropdown-item" href="emergency%20numbers.html">Emergency Numbers</a> </div> </li> <li class="list-item-container nav-item"> <a class="link-text nav-link" href="newmem.html" title="New-Member">NEW MEMBER</a> </li> <li class="list-item-container nav-item"> <a class="link-text nav-link" href="contact.html" title="">CONTACT</a> </li> </ul> <a class="link-text text-link-4" href="https://1066modelflying.club/coppermine/index.php" title="Gallery">GALLERY</a> </div> </nav> <h1>SENIOR RENEWAL FORM</h1> <form name="senior_data" method="post" <fieldset><ledgend>Please enter your infomation in the form below: </legend> <h2>2023 Senior Membership Renewal Form</h2> <p>Please remember that the club & BMFA membership runs out at the end of December. <br> 2023 1066 MFC Membership &#163;10.00<br> BMFA Membership/Insurance &#163;40.00<br> Family Partner Senior &#163;27.00<br> CAA Operator Fee &#163;10.00<br> BMFA Membership Reward Card &#163;4.50<br> British Drone Flyers Association Members &#163;5.00<br> </p><br> <p><b>Name:</b><br> <input type="text" name="name" size="20" maxlength="40"/></p> <label for="dob"><b>Date of birth:</b></label> <input type="date" id="dob" name="dob " value="" min="1900-01-01" max="2050-12-31"> <p><b> <br> <label for="addr">Address:</label><br> <textarea id="addr" name="addr" rows="4" cols="50"> </textarea> <br> <label for="phone">Phone number:</label> <input type="tel" id="phone" name="phone" required> <br> <label for="mob">Mobile number:</label> <input type="tel" id="mob" name="mob" required> <br> <label for="email">Email:</label> <input type="email" id="email" name="email"> <br> <label for="bmfa_no">BMFA No:</label> <input type="text" id="bmfa_no" name="bmfa_no"> <br> <label for="caa_no">CAA Operator No:</label> <input type="text" id="caa_no" name="caa_no"><br> <label for="club_membership">Do you wish that the club obtains your BMFA membership, Insurance & CAA renewal:</label> <select name="club_membership" id="club_membership"> <option value="blank "> </option> <option value="NO">NO</option> <option value="YES">YES</option> </select> <br> <label for="Ctry">Are you a Country Member:</label> <select name="Ctry" id="Ctry"> <option value="blank "> </option> <option value="NO">NO</option> <option value="YES">YES</option> </select> <br> <label for="caa">If you answered YES to the previous question,. have you a current BMFA and CAA membership:</label> <select name="caa" id="caa"> <option value="blank "> </option> <option value="NO">NO</option> <option value="YES">YES</option> <option value="na">N/A</option> </select> <br> <label for="rewd">Do you wish to purchase a BMFA Membership/Reward Card:</label> <select name="rewd" id="rewd"> <option value="blank "> </option> <option value="NO">NO</option> <option value="YES">YES</option> </select> <br> <label for="fam">Are you a family member:</label> <select name="fam" id="fam"> <option value="blank "> </option> <option value="NO">NO</option> <option value="YES">YES</option> </select> <br> <label for="bdf">Do you wish to join the British Drone flyers Association, instead of the BMFA:</label> <select name="bdf" id="bdf"> <option value="blank "> </option> <option value="NO">NO</option> <option value="YES">YES</option> </select> <p>Please note that if you join the BDF you can also fly fixed wing/ helicopters as well!</p> <br> <label for="pay_opt">Ho do you wish to pay:</label> <select name="pay_opt" id="pay_opt"> <option value="blank "> </option> <option value="chq">CHEQUE</option> <option value="csh">CASH</option> <option value="bacs">BACS</option> </select> <br> <p><b>Payment required: &#163;</b><input type="text" name="pay" size="20" maxlength="40"/></p> <br> <p style="background-color:tomato;">I apply for membership of the 1066 Model Flying Club and agree to abide by the rules. By doing so agree to allow the club to use your details in respect of the GDPR regulations for the processing of your renewal, a copy of which can be found on the club website members page. </p> <br> <label for="date">Date:</label> <input type="text" id="date" name="date" pattern="[0-9]{2}/[0-9]{2}/[0-9]{4}" required> <br> <label for="sign">Sign here:</label> <input type="text" id="sign" name=sign" required> <br> <input type="submit" value="submit"> Here is the file that copies the posted output and inserts it into the database: <?php include ("conn/connect_seniorform.php"); $conn=get_db_conn_senior(); if ($_SERVER["REQUEST_METHOD"]== "POST"{ $id = $REQUEST['id']; $name = $REQUEST['name']; $dob = $REQUEST['dob']; $addr = $REQUEST['addr']; $phone= $REQUEST['phone']; $mob = $REQUEST['mob']; $email =$REQUEST['email']; $bmfa_no = $REQUEST['bmfa_no']; $caa_no = $REQUEST['caa_no']; $rewd = $REQUEST['rewd']; $fam = $REQUEST['fam']; $ctry = $REQUEST['ctry']; $ctry_bmfa = $REQUEST['ctry_bmfa']; $bdf = $REQUEST['bdf']; $pay_opt = $REQUEST['pay_opt']; $pay = $REQUEST['pay']; $date = $REQUEST['date']; $sign = $REQUEST['sign']; $sql = "INSERT INTO senior_dat VALUES ($id,$name,$dob,$addr,$phone,$mob,$email,$bmfa_no,$caa_no,$rewd,$fam,$ctry,$ctry_bmfa,$bdf,$pay_opt,$pay,$date,$sign"); if(mysqli_query($conn,$sql)){ echo "<h3> Form saved OK"</h3>; }else{ echo nl2br(You have an input error); } } mysqli_close($conn); ?> I do not get any errors, but nothing appears in the database. As I have not done any php coding in years I used some methods I found on the web. Can anyone tell me where I am going wrong?
  8. I skimmed this thread from the beginning, and while I am not nearly as experienced as those who've been assisting you, I have encountered many issues in coding. My suggestion to you would be to create a NEW simple, form with ONLY one field. <form> <input type="text" name="first"> <input type="submit"> </form> Add a very basic PHP script to create a table with the one field. Load the code with ERROR detection to give you clues to every potential defect. Once you are able to successfully populate the database table with a piece of data from the form, you can THEN expand the code to include additional fields, validation, etc. Create a new version with each effort so that you always have a working template to return to and then just continue to build on the foundation until you have what you wanted. It may take longer, but you will learn and get a better understanding for the future. Good luck.
  9. until you get your code to work for one form field, there's no good point in writing out php code and html markup for all the form fields, that you will need to make multiple changes to before getting it to the point of working. pick one field, such as the visitor's last name (most people have two names and your form and database table needs two fields, so that you can distinguish between the first and last name, for example is someone Martin Ross or Ross Martin.) in the php code, there's actually only one line worth keeping, e.g. checking if a post method form was submitted. you should - have any error related settings in the php.ini on your system so that ALL php detected errors will get reported. the initial php syntax errors present will prevent your code from running at all, so any error related settings in your code won't take effect. use 'require' for things your code must have for it to work and include/require are not functions. the () around the filename are unnecessary clutter. keep the form data as a set, in a php array variable, then operate on elements in this array variable throughout the rest of the code, i.e. don't copy variables to other variables for nothing. this is just a waste of your time typing. as has already been mentioned, use $_POST for the post input data. you also have a mistake in the syntax for $REQUEST (there's an under-score after the $, which is another good reason to get your code to fully work for one form field, before worrying about all the code needed for the rest of the fields.) trim all the input data, mainly so that you can detect if it consists of all white-space characters, before validating it. after you do item #3 on this list, you can trim all the data at once using a single line of php code. validate all the input data before using it, storing user/validation errors in an array, using the field name as the array index. after the end of all the validation logic, if there are no errors (the array will be empty), use the submitted form data. you should switch to the much simpler and more modern PDO database extension, especially since you will be converting this query to be a prepared query in order to prevent any sql special characters in the values from being able to break the sql query syntax, which is how sql injection is accomplished. you should use exceptions for database statement errors and in most cases simply let php catch and handle any database exception. the exception to this rule is when inserting/updating duplicate or out of range user submitted values. in this case, you code should catch the exception, test if the error number is for something that your code is designed to handle, such as a duplicate index error for fields that must be unique, e.g. the email field, and setup a message telling the visitor exactly what was wrong with the data that they submitted. for all other error numbers, just rethrow the exception and let php handle it. list out the columns you are providing values for in the insert query. this will let you eliminate things like the id column, which the value you are currently attempting to provide doesn't exist, e.g. there's no id field in the form and any php code referencing it will be producing php errors. if you were putting values directly into the sql query statement (you won't be when using a prepared query), you would need to put single-quotes around any literal string values, so that they don't produce sql errors about non-existent columns named the same as the data values. not sure why you are applying nl2br() to a value that doesn't have any new-line characters in it. after the end of all the post method form processing logic, if there are no errors, you would preform a redirect to the exact same url of the current page to cause a get request for that page. any redirect needs an exit/die statement after it to stop php code execution. to display a one-time success message, store it in a session variable, then test, display, and clear the session variable at the appropriate location in the html document. if at item #7 or #13 on this list, there are errors, your code will continue on to redisplay the html document, display any user/validation errors, redisplay the form, repopulating the form field values/selections with the existing values, so that the user doesn't need to keep re-entering data over and over when there are errors. any external, unknown, dynamic value that you output in a html context should have htmlentities() applied to it when it is being output, to help prevent cross site scripting. there's no good point in closing database connections since php will automatically destroy everything that was created on a page when your script ends.
  10. Managed to figure that out, but have another problem! Parse error: syntax error, unexpected end of file in C:\wamp64\www Im know that this can be un-equal curly brackets, but they look OK. On the web it said that it can be an unclosed php code. Looking at the code, you have <? but within quotes? Is the error check mistaking them for php code terminator? Here is the file: <?php // initialization session_start(); error_reporting(E_ALL); ini_set('display_errors','1'); // why not have the connection code actually make the connection too, so that you don't need another line of code? require "conn/connect_seniorform.php"; // note: this code uses the much simpler and more modern PDO database extension // when you make the connection - // set the character set to match your database tables, so that no character conversion occurs over the connection // set the error mode to use exceptions, so that all the database statements will use exceptions (this is the default now in php8, but set it anyways) // set emulated prepared queries to false, you want to run real prepared queries // set the default fetch mode to assoc, so that you don't need to specify it in each fetch statement $post = []; // array to hold a trimmed working copy of the form data $errors = []; // array to hold user/validation errors // post method form processing $status=""; if($_SERVER["REQUEST_METHOD"]=="POST"){ $fname=$POST['fname']; $lname=$POST['lname']; $email=$POST['email']; if(empty($fname)|| empty($lname)|| $email){ $status="All fields are compulsory."; }else{ if(strlen($fname)>= 255 || !preg_match("/^[a-zA-Z-'\s+$/", $fname)){ $status="Please enter a valid name"; }else{ if(!filter_var($email, FILTER_VALIDATE_EMAIL)){ $status="Please Enter a valid email"; }else{ $sql="INSERT INTO senior_dat(fname,lname) VALUES (:fname, :lname)"; $stmt=$pdo->prepare($sql); $stmt->execute(['fname'=>$fname], ['lname'=>$lname]); $status="Your entrys have been accepted"; $fname=""; $email=""; } } } // hrml document starts here... ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="generator" content="RSD 5.0.3519"> <title>Senior Form</title> <link rel="stylesheet" href="css/bootstrap4.min.css"> <link rel="stylesheet" href="css/wireframe-theme.min.css"> <script>document.createElement( "picture" );</script> <script class="picturefill" async="async" src="js/picturefill.min.js"></script> <link rel="stylesheet" href="css/main.css"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Averia+Sans+Libre:400,b%7CRoboto:400,900,b"> </head> <body class="body-3"><div class="responsive-picture picture-1 align-content-md-center"> <picture> <img alt="Placeholder Picture" width="1200" height="300" src="./images/1066MFC%20Banner.jpg" loading="lazy"> </picture> </div> <nav class="container-grid navbar navbar-expand-lg navbar-dark bg-dark"> <h3 class="navbar-brand">MENU</h3><button type="button" class="btn navbar-toggler navbar-toggler-icon button Dropdown-toggle" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-label="Toggle navigation"></button> <div class="container-grid collapse navbar-collapse" id="navbarNavDropdown"> <ul class="list-container navbar-nav"> <li class="list-item-container nav-item"> <a class="link-text nav-link" href="index.html" title="">HOME</a> </li> <li class="list-item-container nav-item"> <a class="link-text nav-link" href="about.html" title="">ABOUT</a> </li> <li class="list-item-container nav-item dropdown"> <a class="link-text nav-link dropdown-toggle" href="members.html#navbarNavDropdown" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">MEMBERS</a> <div class="container-grid dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> <a class="link-text dropdown-item" href="members.html" title="">Members</a> <a class="link-text dropdown-item" href="aerodrome.html" title="PEBSHAM AERODROME">Pebsham Aerodrome</a> <a class="link-text dropdown-item" href="emergency%20numbers.html">Emergency Numbers</a> </div> </li> <li class="list-item-container nav-item"> <a class="link-text nav-link" href="newmem.html" title="New-Member">NEW MEMBER</a> </li> <li class="list-item-container nav-item"> <a class="link-text nav-link" href="contact.html" title="">CONTACT</a> </li> </ul> <a class="link-text text-link-4" href="https://1066modelflying.club/coppermine/index.php" title="Gallery">GALLERY</a> </div> </nav> <?php // display and clear any success message if(!empty($_SESSION['success_message'])) { echo "<p>{$_SESSION['success_message']}</p>"; unset($_SESSION['success_message']); } ?> <h1>SENIOR RENEWAL FORM</h1> <?php // display any errors if(!empty($errors)) { echo '<p>'; echo implode('<br>',$errors); echo '</p>'; } ?> <form method="post"> <label><b>First Name:</b><br><input type="text" name="first_name" size="20" maxlength="40" value="<?=htmlentities($post['fname']??'',ENT_QUOTES)?>"></label> <br> <label><b>Last Name:</b><br><input type="text" name="first_name" size="20" maxlength="40" value="<?=htmlentities($post['lname']??'',ENT_QUOTES)?>"></label> <br> <label><b>email:</b><br><input type="text" name="first_name" size="20" maxlength="40" value="<?=htmlentities($post['email']??'',ENT_QUOTES)?>"></label> <br> <input type="submit" value="submit"> </form> </body> </html>
  11. I copied the code you posted and got all your errors on fname etc. I then made those 2 changes and all the errors went away. This is your code with those two { } errors fixed. This doesn't mean you have more that aren't showing yet. <?php session_start(); error_reporting (E_ALL); ini_set('display_errors','1'); $errors = array(); #require "conn/connect_seniorform.php"; // MORE PHP CODE IF ANY if($_SERVER["REQUEST_METHOD"] == "POST") { // read the inputs if (isset ($_POST['fname'])){ $fname = htmlentities($_POST['fname'],ENT_QUOTES);} if (isset ($_POST['sname'])){ $sname = htmlentities($_POST['sname'],ENT_QUOTES);} if (isset ($_POST['email'])){ $email = htmlentities($_POST['email'],ENT_QUOTES);} if (isset ($_POST['addr'])){ $addr = htmlentities($_POST['addr'],ENT_QUOTES);} if (isset ($_POST['phone'])){ $phone = htmlentities($_POST['phone'],ENT_QUOTES);} if (isset ($_POST['mob'])){ $mob = htmlentities($_POST['mob'],ENT_QUOTES); } if (isset($_POST['bmfa_no'])){ $bmfa_no = htmlentities($_POST['bmfa_no'],ENT_QUOTES);} if (isset($_POST['caa_no'])){ $caa_no = htmlentities($_POST['caa_no'],ENT_QUOTES);} if (isset ($_POST['rewd'])){ $rewd = htmlentities($_POST['rewd'],ENT_QUOTES);} if (isset ($_POST['fam'])){ $fam = htmlentities($_POST['fam'],ENT_QUOTES);} if (isset($_POST['ctry'])){ $ctry = htmlentities($_POST['ctry'],ENT_QUOTES);} if (isset($_POST['ctry_bmfa'])){ $ctry_bmfa = htmlentities($_POST['ctry_bmfa'],ENT_QUOTES);} if (isset ($_POST['bdf'])){ $bdf = htmlentities($_POST['bdf'],ENT_QUOTES);} if (isset($_POST['payopt'])){ $payopt = htmlentities($_POST['payopt'],ENT_QUOTES);} if (isset ($_POST['payopt'])){ $pay = htmlentities($_POST['pay'],ENT_QUOTES);} if (isset ($_POST['date'])){ $date = htmlentities($_POST['date'],ENT_QUOTES);} if (isset ($_POST['sign'])){ $sign = htmlentities($_POST['sign'],ENT_QUOTES);} // process the data now if (count($errors) == 0) { $sql = "INSERT INTO senior_dat(fname,sname,email,dob,addr,phone,mob,bmfa_no,caa_no,rewd,fam,ctry,ctry_bmfa,bdf,payopt,pay,date,sign) VALUES (:fname, :sname, :email,:dob, :addr, :phone, :mob, :bmfa_no, :caa_no, :rewd, :fam, :ctry, :ctry_bmfa, :bdf, :payopt, :pay, :date, :sign)"; $stmt = $pdo->prepare($sql); $parms = array( 'fname'=>$fname, 'sname'=>$sname, 'email'=>$email, 'addr'=>$addr, 'phone'=>$phone, 'mob'=>$mob, 'bmfa_no'=>$bmfa_no, 'caa_no'=>$caa_no, 'rewd'=>$rewd, 'fam'=>$fam, 'ctry'=>$ctry, 'ctry_bmfa'=>$ctry_bmfa, 'bdf'=>$bdf, 'payopt'=>$payopt, 'pay'=>$pay, 'date'=>$date, 'sign'>$sign ); if (!$stmt->execute($parms)) $errors[] = "Insert query did not run"; else $errors[] = "Your entries have been accepted"; } } else // no inputs yet { $fname = ''; $sname = ''; $email = ''; $addr = ''; $phone = ''; $mob = ''; $bmfa_no = ''; $caa_no = ''; $rewd = ''; $fam = ''; $ctry = ''; $ctry_bmfa = ''; $bdf = ''; $pay_opt = ''; $pay = ''; $date = ''; $sign = ''; } // Done with the inputs - redisplay the form screen with the messages we produced. // // implode the errrors array to show the result message or the errors $errmsg = implode('<br>', $errors); echo " <!DOCTYPE html> <html lang='en'> <head> <style type='text/css'> #form_box { position:relative; float:left; margin:3% 1%; padding:5px; border:2px solid black; } .red{color:red;} </style> </head> <body> "; echo " <div id='form_box'> <center> <h1>SENIOR RENEWAL FORM</h1> </center> "; if(!empty($errmsg)) echo "<p class='red'>$errmsg</p>"; echo " <form method='POST'> <label><b>First Name: </b> <br> <input type='text' name='fname' size='20' maxlength='40' value='$fname' required> </label> <br> <label><b>Surname: </b> <br> <input type='text' name='sname' size='20' maxlength='40' value='$sname' required> </label> <br> <label><b>Email: </b> <br> <input type='text' name='email' size='20' maxlength='40' value='$email' required> </label> <br><br> <label><b>Address: </b> <br> <input type='textarea' name='addr' rows='4' cols='50 value='$addr' required> </label> <br> <label><b>Phone number:</br> <input type='tel' name='phone' 'min=12' max=16' value='$phone' required> </label> <br> <label> <b>Mobile number:</br> <input type='tel' name='mob' 'min=12' 'max=16' value'$mob' required> </label> <br> <label BMFA No: <input type='number' name='bmfa_no' value='$bmfa_no' required> </label> <br> <label CAA Operator No: <input type='text' name='caa_no' value='$caa_no' required><br> </label> <label Do you wish that the club obtains your BMFA membership, Insurance & CAA renewal: <select name='club_membership' id='club_membership'> <option value='Select Yes or No'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> </label> <br> <label for='Ctry'>Are you a Country Member:</label> <select name='Ctry' id='Ctry'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='caa'>If you answered YES to the previous question,. have you a current BMFA and CAA membership:</label> <select name='caa' id='caa'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> <option value='na'>N/A</option> </select> <br> <label for='rewd'>Do you wish to purchase a BMFA Membership/Reward Card:</label> <select name='rewd' id='rewd'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='fam'>Are you a family member:</label> <select name='fam' id='fam'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='bdf'>Do you wish to join the British Drone flyers Association, instead of the BMFA:</label> <select name='bdf' id='bdf'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <p>Please note that if you join the BDF you can also fly fixed wing/ helicopters as well!</p> <br> <label for='pay_opt'>Ho do you wish to pay:</label> <select name='pay_opt' id='pay_opt'> <option value='blank'> </option> <option value='chq'>CHEQUE</option> <option value='csh'>CASH</option> <option value='bacs'>BACS</option> </select> <br> <p><b>Payment required: &#163;</b><input type='text' name='pay' size='20' maxlength='40'/></p> <br> <p style='background-color:tomato;'>I apply for membership of the 1066 Model Flying Club and agree to abide by the rules. By doing so agree to allow the club to use your details in respect of the GDPR regulations for the processing of your renewal, a copy of which can be found on the club website members page. </p> <br> <label for='date'>Date:</label> <input type='text' id='date' name='date' pattern='[0-9]{2}/[0-9]{2}/[0-9]{4}' required> <br> <label for='sign'>Sign here:</label> <input type='text' id='sign' name='sign' required> <br> <input type='submit' value='Submit'> </form> </div> "; and the error-free output...
  12. Which line exactly is 131? Show it HERE Please do the following: 1 - you should have only one '<form' tag and only one '</form' tag. Please confirm 2 - the contents of that form between the 2 form tags should have a submit button ie. "<input type='submit'" . Confirmed? 3 - the line 131 should be this one by my reckoning: <form method='POST'> <label><b>First Name: </b> <br> <!--- LINE 131 BELOW --> <input type='text' name='fname' size='20' maxlength='40' value='$fname' required> </label> If all 3 of my question are true then I have no idea what else you have in your code that is causing the problem. I'm guessing it is something to do with the initialization of all your php vars when you don't detect a POST array. One thing we could do is move that block to define all the vars before you begin any code.
  13. Ginerjm Here is the section with lines in error: <form method='POST'> <label><b>First Name: </b> <br> <input type='text' name='fname' size='20' maxlength='40' value='$fname' required> </label> <br> <label><b>Surname: </b> <br> <input type='text' name='sname' size='20' maxlength='40' value='$sname' required> </label> <br> <label><b>Email: </b> <br> <input type='text' name='email' size='20' maxlength='40' value='$email' required> </label> <br><br> <label><b>Address: </b> <br> <input type='textarea' name='addr' rows='4' cols='50 value='$addr' required> </label> <br> <label><b>Phone number:</br> <input type='tel' name='phone' 'min=12' max=16' value='$phone' required> </label> <br> <label> <b>Mobile number:</br> <input type='tel' name='mob' 'min=12' 'max=16' value'$mob' required> </label> <br> <label BMFA No: <input type='number' name='bmfa_no' value='$bmfa_no' required> </label> <br> <label CAA Operator No: <input type='text' name='caa_no' value='$caa_no' required><br> </label> See the attached picture for which lines are in error. thank you!
  14. Hi Ginerjm Here is the code: <?php session_start(); error_reporting (E_ALL); ini_set('display_errors','1'); $errors = array(); require "conn/connect_seniorform.php"; // MORE PHP CODE IF ANY if($_SERVER["REQUEST_METHOD"] == "POST") { // read the inputs if (isset ($_POST['fname'])){ $fname = htmlentities($_POST['fname'],ENT_QUOTES);} if (isset ($_POST['sname'])){ $sname = htmlentities($_POST['sname'],ENT_QUOTES);} if (isset ($_POST['email'])){ $email = htmlentities($_POST['email'],ENT_QUOTES);} if (isset ($_POST['addr'])){ $addr = htmlentities($_POST['addr'],ENT_QUOTES);} if (isset ($_POST['phone'])){ $phone = htmlentities($_POST['phone'],ENT_QUOTES);} if (isset ($_POST['mob'])){ $mob = htmlentities($_POST['mob'],ENT_QUOTES); if (isset($_POST['bmfa_no'])){ $bmfa_no = htmlentities($_POST['bmfa_no'],ENT_QUOTES);} if (isset($_POST['caa_no'])){ $caa_no = htmlentities($_POST['caa_no'],ENT_QUOTES);} if (isset ($_POST['rewd'])){ $rewd = htmlentities($_POST['rewd'],ENT_QUOTES);} if (isset ($_POST['fam'])){ $fam = htmlentities($_POST['fam'],ENT_QUOTES);} if (isset($_POST['ctry'])){ $ctry = htmlentities($_POST['ctry'],ENT_QUOTES);} if (isset($_POST['ctry_bmfa'])){ $ctry_bmfa = htmlentities($_POST['ctry_bmfa'],ENT_QUOTES);} if (isset ($_POST['bdf'])){ $bdf = htmlentities($_POST['bdf'],ENT_QUOTES);} if (isset($_POST['payopt'])){ $payopt = htmlentities($_POST['payopt'],ENT_QUOTES);} if (isset ($_POST['payopt'])){ $pay = htmlentities($_POST['pay'],ENT_QUOTES);} if (isset ($_POST['date'])){ $date = htmlentities($_POST['date'],ENT_QUOTES);} if (isset ($_POST['sign'])){ $sign = htmlentities($_POST['sign'],ENT_QUOTES);} // process the data now if (count($errors) == 0) { $sql = "INSERT INTO senior_dat(fname,sname,email,dob,addr,phone,mob,bmfa_no,caa_no,rewd,fam,ctry,ctry_bmfa,bdf,payopt,pay,date,sign) VALUES (:fname, :sname, :email,:dob, :addr, :phone, :mob, :bmfa_no, :caa_no, :rewd, :fam, :ctry, :ctry_bmfa, :bdf, :payopt, :pay, :date, :sign)"; $stmt = $pdo->prepare($sql); $parms = array( 'fname'=>$fname, 'sname'=>$sname, 'email'=>$email, 'addr'=>$addr, 'phone'=>$phone, 'mob'=>$mob, 'bmfa_no'=>$bmfa_no, 'caa_no'=>$caa_no, 'rewd'=>$rewd, 'fam'=>$fam, 'ctry'=>$ctry, 'ctry_bmfa'=>$ctry_bmfa, 'bdf'=>$bdf, 'payopt'=>$payopt, 'pay'=>$pay, 'date'=>$date, 'sign'>$sign ); if (!$stmt->execute($parms)) $errors[] = "Insert query did not run"; else $errors[] = "Your entries have been accepted"; } } else // no inputs yet { $fname = ''; $sname = ''; $email = ''; $addr = ''; $phone = ''; $mob = ''; $bmfa_no = ''; $caa_no = ''; $rewd = ''; $fam = ''; $ctry = ''; $ctry_bmfa = ''; $bdf = ''; $pay_opt = ''; $pay = ''; $date = ''; $sign = ''; } } // Done with the inputs - redisplay the form screen with the messages we produced. // // implode the errrors array to show the result message or the errors $errmsg = implode('<br>', $errors); echo " <!DOCTYPE html> <html lang='en'> <head> <style type='text/css'> #form_box { position:relative; float:left; margin:3% 1%; padding:5px; border:2px solid black; } .red{color:red;} </style> </head> <body> "; echo " <div id='form_box'> <center> <h1>SENIOR RENEWAL FORM</h1> </center> "; if(!empty($errmsg)) echo "<p class='red'>$errmsg</p>"; echo " <form method='POST'> <label><b>First Name: </b> <br> <input type='text' name='fname' size='20' maxlength='40' value='$fname' required> </label> <br> <label><b>Surname: </b> <br> <input type='text' name='sname' size='20' maxlength='40' value='$sname' required> </label> <br> <label><b>Email: </b> <br> <input type='text' name='email' size='20' maxlength='40' value='$email' required> </label> <br><br> <label><b>Address: </b> <br> <input type='textarea' name='addr' rows='4' cols='50 value='$addr' required> </label> <br> <label><b>Phone number:</br> <input type='tel' name='phone' 'min=12' max=16' value='$phone' required> </label> <br> <label> <b>Mobile number:</br> <input type='tel' name='mob' 'min=12' 'max=16' value'$mob' required> </label> <br> <label BMFA No: <input type='number' name='bmfa_no' value='$bmfa_no' required> </label> <br> <label CAA Operator No: <input type='text' name='caa_no' value='$caa_no' required><br> </label> <label Do you wish that the club obtains your BMFA membership, Insurance & CAA renewal: <select name='club_membership' id='club_membership'> <option value='Select Yes or No'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> </label> <br> <label for='Ctry'>Are you a Country Member:</label> <select name='Ctry' id='Ctry'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='caa'>If you answered YES to the previous question,. have you a current BMFA and CAA membership:</label> <select name='caa' id='caa'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> <option value='na'>N/A</option> </select> <br> <label for='rewd'>Do you wish to purchase a BMFA Membership/Reward Card:</label> <select name='rewd' id='rewd'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='fam'>Are you a family member:</label> <select name='fam' id='fam'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='bdf'>Do you wish to join the British Drone flyers Association, instead of the BMFA:</label> <select name='bdf' id='bdf'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <p>Please note that if you join the BDF you can also fly fixed wing/ helicopters as well!</p> <br> <label for='pay_opt'>Ho do you wish to pay:</label> <select name='pay_opt' id='pay_opt'> <option value='blank'> </option> <option value='chq'>CHEQUE</option> <option value='csh'>CASH</option> <option value='bacs'>BACS</option> </select> <br> <p><b>Payment required: &#163;</b><input type='text' name='pay' size='20' maxlength='40'/></p> <br> <p style='background-color:tomato;'>I apply for membership of the 1066 Model Flying Club and agree to abide by the rules. By doing so agree to allow the club to use your details in respect of the GDPR regulations for the processing of your renewal, a copy of which can be found on the club website members page. </p> <br> <label for='date'>Date:</label> <input type='text' id='date' name='date' pattern='[0-9]{2}/[0-9]{2}/[0-9]{4}' required> <br> <label for='sign'>Sign here:</label> <input type='text' id='sign' name='sign' required> <br> <input type='submit' value='Submit'> </form> </div> "; exit(); Thank for your help!
  15. I'm new to PDO and am not yet familiar with the language. I am designing a form and am having problems with the prepare statement. The error is on this line: The $conn is my connection code and $sql is an INSERT query. The data for the query is obtained from a form within this file using $_POST. Here is the complete file: <?php session_start(); error_reporting (E_ALL); ini_set('display_errors','1'); $errors = array(); $conn=''; require_once "conn/connect_seniorform.php"; // MORE PHP CODE IF ANY if($_SERVER["REQUEST_METHOD"] == "POST") { // read the inputs if (isset ($_POST['fname'])){ $fname = htmlentities($_POST['fname'],ENT_QUOTES);} if (isset ($_POST['sname'])){ $sname = htmlentities($_POST['sname'],ENT_QUOTES);} if (isset ($_POST['email'])){ $email = htmlentities($_POST['email'],ENT_QUOTES);} if (isset ($_POST['addr'])){ $addr = htmlentities($_POST['addr'],ENT_QUOTES);} if (isset ($_POST['phone'])){ $phone = htmlentities($_POST['phone'],ENT_QUOTES);} if (isset ($_POST['mob'])){ $mob = htmlentities($_POST['mob'],ENT_QUOTES); } if (isset($_POST['bmfa_no'])){ $bmfa_no = htmlentities($_POST['bmfa_no'],ENT_QUOTES);} if (isset($_POST['caa_no'])){ $caa_no = htmlentities($_POST['caa_no'],ENT_QUOTES);} if (isset ($_POST['rewd'])){ $rewd = htmlentities($_POST['rewd'],ENT_QUOTES);} if (isset ($_POST['fam'])){ $fam = htmlentities($_POST['fam'],ENT_QUOTES);} if (isset($_POST['ctry'])){ $ctry = htmlentities($_POST['ctry'],ENT_QUOTES);} if (isset($_POST['ctry_bmfa'])){ $ctry_bmfa = htmlentities($_POST['ctry_bmfa'],ENT_QUOTES);} if (isset ($_POST['bdf'])){ $bdf = htmlentities($_POST['bdf'],ENT_QUOTES);} if (isset($_POST['payopt'])){ $payopt = htmlentities($_POST['payopt'],ENT_QUOTES);} if (isset ($_POST['payopt'])){ $pay = htmlentities($_POST['pay'],ENT_QUOTES);} if (isset ($_POST['date'])){ $date = htmlentities($_POST['date'],ENT_QUOTES);} if (isset ($_POST['sign'])){ $sign = htmlentities($_POST['sign'],ENT_QUOTES);} // process the data now if (count($errors) == 0) { $sql = "INSERT INTO senior_dat(fname,sname,email,dob,addr,phone,mob,bmfa_no,caa_no,rewd,fam,ctry,ctry_bmfa,bdf,payopt,pay,date,sign) VALUES (:fname, :sname, :email,:dob, :addr, :phone, :mob, :bmfa_no, :caa_no, :rewd, :fam, :ctry, :ctry_bmfa, :bdf, :payopt, :pay, :date, :sign)"; $stmt = $conn->prepare($sql); //<<< error here $parms = array( 'fname'=>$fname, 'sname'=>$sname, 'email'=>$email, 'addr'=>$addr, 'phone'=>$phone, 'mob'=>$mob, 'bmfa_no'=>$bmfa_no, 'caa_no'=>$caa_no, 'rewd'=>$rewd, 'fam'=>$fam, 'ctry'=>$ctry, 'ctry_bmfa'=>$ctry_bmfa, 'bdf'=>$bdf, 'payopt'=>$payopt, 'pay'=>$pay, 'date'=>$date, 'sign'>$sign ); if (!$stmt->execute($parms)) $errors[] = "Insert query did not run"; else $errors[] = "Your entries have been accepted"; } } else // no inputs yet { $fname = ''; $sname = ''; $email = ''; $addr = ''; $phone = ''; $mob = ''; $bmfa_no = ''; $caa_no = ''; $rewd = ''; $fam = ''; $ctry = ''; $ctry_bmfa = ''; $bdf = ''; $pay_opt = ''; $pay = ''; $date = ''; $sign = ''; } // Done with the inputs - redisplay the form screen with the messages we produced. // // implode the errrors array to show the result message or the errors $errmsg = implode('<br>', $errors); echo " <!DOCTYPE html> <html lang='en'> <head> <style type='text/css'> #form_box { position:relative; float:left; margin:3% 1%; padding:5px; border:2px solid black; } .red{color:red;} </style> </head> <body> "; echo " <div id='form_box'> <center> <h1>SENIOR RENEWAL FORM</h1> </center> "; if(!empty($errmsg)) echo "<p class='red'>$errmsg</p>"; echo " <form method='POST'> <label><b>First Name: </b> <br> <input type='text' name='fname' size='20' maxlength='40' value='$fname' required> </label> <br> <label><b>Surname: </b> <br> <input type='text' name='sname' size='20' maxlength='40' value='$sname' required> </label> <br> <label><b>Email: </b> <br> <input type='text' name='email' size='20' maxlength='40' value='$email' required> </label> <br><br> <label><b>Address: </b> <br> <input type='textarea' name='addr' rows='4' cols='50 value='$addr' required> </label> <br> <label><b>Phone number:</br> <input type='tel' name='phone' 'min=12' max=16' value='$phone' required> </label> <br> <label> <b>Mobile number:</br> <input type='tel' name='mob' 'min=12' 'max=16' value'$mob' required> </label> <br> <label BMFA No: <input type='number' name='bmfa_no' value='$bmfa_no' required> </label> <br> <label CAA Operator No: <input type='text' name='caa_no' value='$caa_no' required><br> </label> <label Do you wish that the club obtains your BMFA membership, Insurance & CAA renewal: <select name='club_membership' id='club_membership'> <option value='Select Yes or No'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> </label> <br> <label for='Ctry'>Are you a Country Member:</label> <select name='Ctry' id='Ctry'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='caa'>If you answered YES to the previous question,. have you a current BMFA and CAA membership:</label> <select name='caa' id='caa'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> <option value='na'>N/A</option> </select> <br> <label for='rewd'>Do you wish to purchase a BMFA Membership/Reward Card:</label> <select name='rewd' id='rewd'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='fam'>Are you a family member:</label> <select name='fam' id='fam'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <br> <label for='bdf'>Do you wish to join the British Drone flyers Association, instead of the BMFA:</label> <select name='bdf' id='bdf'> <option value='blank'> </option> <option value='NO'>NO</option> <option value='YES'>YES</option> </select> <p>Please note that if you join the BDF you can also fly fixed wing/ helicopters as well!</p> <br> <label for='pay_opt'>Ho do you wish to pay:</label> <select name='pay_opt' id='pay_opt'> <option value='blank'> </option> <option value='chq'>CHEQUE</option> <option value='csh'>CASH</option> <option value='bacs'>BACS</option> </select> <br> <p><b>Payment required: &#163;</b><input type='text' name='pay' size='20' maxlength='40'/></p> <br> <p style='background-color:tomato;'>I apply for membership of the 1066 Model Flying Club and agree to abide by the rules. By doing so agree to allow the club to use your details in respect of the GDPR regulations for the processing of your renewal, a copy of which can be found on the club website members page. </p> <br> <label for='date'>Date:</label> <input type='text' id='date' name='date' pattern='[0-9]{2}/[0-9]{2}/[0-9]{4}' required> <br> <label for='sign'>Sign here:</label> <input type='text' id='sign' name='sign' required> <br> <input type='submit' value='Submit'> </form> </div> "; I hope someone can help me?
  16. You know - you don't really have to repeat every post when you make a response..... Here is the sample //******************************* //******************************* function DisplayPage() { global $action, $errmsg, $hide, $focusid, $ah_php_path, $show_div_titles, $show_borders; /* hide is to turn on/off input tags that are hidden ah_php_path is the path to my saved modules that get used here The show.... vars are to enable showing the titles of my div tags and their borders if I am rearranging things during page design. focusid is used by my php to set focus on different inputs */ if ($show_div_titles) $div_title = ''; else $div_title = "title=''"; if ($show_borders) $border = " style='border:1px solid white; '"; else $border = ''; $code=<<<heredocs <!DOCTYPE html> <html lang='en'> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>xxx</title> <style type="text/css"> body { height:100%; width: 100%; margin: 0px; padding: 0px; border: none; background-color:#c0c0c0; font-family:'Segoe UI','Trebuchet MS',Tahoma,Arial,Sans-serif; } p, h1, h2, h3, h4, h5, h6 { margin:0px; padding:0px; } .bold {font-weight:600;} .red { color:red;} .black {color:black;} .yellow {color:yellow;} .orange { color:#f71602; font-weight:800; } label,input {font-size:16px;} input { color:black; background-color:white; } .smltxt {font-size:12px;} .regtxt {font-size:18px;} .medtxt {font-size:22px;} .lgtxt {font-size:26px;} #form_box { position:relative; float:left; margin:1% 1%; padding:10px; border:1px solid yellow; } /* MEDIA QUERY */ /* MEDIA QUERY */ /* MEDIA QUERY */ @media screen and (max-width: 600px) { #form_box { position:relative; float:left; margin:1% 1%; padding:10px; border:1px solid yellow; } label,input{font-size:14px;} .smltxt {font-size:12px;} .regtxt {font-size:16px;} .medtxt {font-size:20px;} .lgtxt {font-size:24px;} } /* end of media query */ </style> heredocs; echo $code; require $ah_php_path . 'js/setFocus.js'; $code =<<<heredocs </head> <body bgcolor='#c0c0c0' onload='setFocus("$focusid")'> <center> <span class='lgtxt'> xxx Page Title </span> </center> <br> <span class='red regtxt'> $errmsg </span> <div id='form_box' $border $div_title title='form_box'> <form name='thisform' method='POST' action='$action' autocomplete='off'> <input type='submit' name='btn' id='rtnbtn' value='Return' accesskey='r'> </form> </div> <br> </body> </html> heredocs; echo $code; } Any new divs of forms that you create with your php you place into a var and then add that var to the global line and put it where you want that code to appear. I do very little php in this function as you can see.
  17. I dont know where to put this controller in my index my proffessor wants this in and I dont know where to put it and why. $action == 'list_students' My index so far <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Davids Database</title> <!-- David Malone Computer Science 4000 --> <link rel="stylesheet" href="../style.css"> </head> <body> <?php include ('../view/Header.php'); ?> <section> <table style ="width: 500px"> <tr> <td style ="width: 100px"><b>StudentID</b></td> <td style ="width: 100px"><b>MajorID</b></td> <td style ="width: 100px"><b>FirstName</b></td> <td style ="width: 100px"><b>LastName</b></td> <td><b>Gender</b></td> </tr> </table> $action == list_students <?php require ('delete.php'); require ('../model/major.php'); /* First time running page This generates the table */ if (isset($_GET['majorID'])){} else getID(1); /* Detects when buttons are clicked and calls function using value in button */ if (array_key_exists('DELETE', $_POST)) { $student_id = $_POST ['DELETE']; delStudent($student_id); } if (array_key_exists('majorID', $_GET)) { $majorID = $_GET ['majorID']; getID($majorID); } ?> <a href="../student_manager/add student.php">Add Student</a><br> <form action="" method"get"> <button type="submit" name="majorID" value="1"> Show Computer Science Majors</button><br><br> <button type="submit" name="majorID" value="2"> Show Electrical Engineering Majors</button><br><br> <button type="submit" name="majorID" value="3"> Show Business Majors</button> </form> </section> <?php include ('../view/Footer.php'); ?> </body> </html>
  18. <?php namespace xosad; class InstaAccountBot { private $csrftoken; private $name; private $email; private $username; private $password; private $headers = array(); private $user_agent = "Mozilla/5.0 (Linux; Android 7.1.1; ONEPLUS A5000 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36"; private function randomPassword() { $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; $pass = array(); $alphaLength = strlen($alphabet) - 1; for ($i = 0; $i < 15; $i++) { $n = rand(0, $alphaLength); $pass[] = $alphabet[$n]; } return implode($pass); } private function getToken($username) { $cookie = file_get_contents('cookies/'.$username.'.txt'); $csrftoken = '/csrftoken\s(.*)\s/mU'; preg_match_all($csrftoken, $cookie, $csrftoken, PREG_SET_ORDER, 0); $csrftoken = $csrftoken[0][1]; if($csrftoken != ""){ return $csrftoken; }else{ exit; } } private function generateClientId(){ $strUrl = 'https://www.instagram.com/web/__mid/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$strUrl); curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $result = curl_exec($ch); curl_close ($ch); return $result; } private function usr2id($username) { $user_id = file_get_contents('https://www.instagram.com/' . $username . '/'); $re = '/sharedData\s=\s(.*[^\"]);<.script>/ixU'; preg_match_all($re, $user_id, $id_username, PREG_SET_ORDER); $data = json_decode($id_username[0][1], true); $id = $data['entry_data']['ProfilePage']['0']['graphql']['user']['id']; return $id; } private function generateCsrfToken() { $strUrl = 'https://www.instagram.com/data/shared_data/?__a=1'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$strUrl); curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $result = curl_exec($ch); curl_close ($ch); $json = json_decode($result , true); return $json['config']['csrf_token']; } private function getAccountData() { $strUrl = 'https://randomuser.me/api/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$strUrl); curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $result = curl_exec($ch); curl_close ($ch); $json = json_decode($result , true); $this->name = $json['results']['0']['name']['first'].' '.$json['results']['0']['name']['last']; $this->email = $json['results']['0']['login']['username'].'we3z'.'@'.'gmail.com'; $this->username = $json['results']['0']['login']['username'].'we3z'; return true; } public function createAccount($proxy = null) { $this->csrftoken = $this->generateCsrfToken(); $this->password = $this->randomPassword(); $this->getAccountData(); $headers = $this->headers; $headers[] = 'accept: */*'; $headers[] = 'accept-encoding: gzip, deflate, br'; $headers[] = 'accept-language: en-GB,en-US;q=0.9,en;q=0.8'; $headers[] = 'content-type: application/x-www-form-urlencoded'; $headers[] = 'origin: https://www.instagram.com'; $headers[] = 'referer: https://www.instagram.com/'; $headers[] = 'x-csrftoken: '.$this->csrftoken; $headers[] = 'x-ig-app-id: 936619743392459'; $headers[] = 'x-instagram-ajax: 1'; $headers[] = 'x-requested-with: XMLHttpRequest'; $arrPostData = array(); $arrPostData['email'] = $this->email; $arrPostData['password'] = $this->password; $arrPostData['username'] = $this->username; $arrPostData['first_name'] = $this->name; $arrPostData['client_id'] = $this->generateClientId(); $arrPostData['seamless_login_enabled'] = '1'; $arrPostData['gdpr_s'] = '%5B0%2C2%2C0%2Cnull%5D'; $arrPostData['tos_version'] = 'eu'; $arrPostData['opt_into_one_tap'] = 'false'; $strUrl = 'https://www.instagram.com/accounts/web_create_ajax/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$strUrl); curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); curl_setopt($ch, CURLOPT_COOKIE, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); if($proxy !== null) { curl_setopt($ch, CURLOPT_PROXY , $proxy); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); } curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arrPostData)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $result = curl_exec($ch); if(curl_errno($ch) !== 28 AND $result !== false) { $json = json_decode($result, true); if($json['account_created'] !== false AND $json['status'] !== 'fail') { $data_array = [ 'created' => true, 'username' => $this->username, 'password' => $this->password, 'email' => $this->email, 'name' => $this->name, 'registered_proxy' => $proxy ]; $json = file_get_contents('accounts.json'); $data = json_decode($json); $data[] = $data_array; file_put_contents('accounts.json', json_encode($data)); curl_close ($ch); return json_encode($data).PHP_EOL; }else { curl_close ($ch); return $result.PHP_EOL; } }else{ $error = curl_error($ch).PHP_EOL; curl_close ($ch); return $error; } } public function loginAndFollow($username , $password , $proxy = null , array $accounts = null) { $this->csrftoken = $this->generateCsrfToken(); $headers = $this->headers; $headers[] = 'accept: */*'; $headers[] = 'accept-encoding: gzip, deflate, br'; $headers[] = 'accept-language: en-GB,en-US;q=0.9,en;q=0.8'; $headers[] = 'content-type: application/x-www-form-urlencoded'; $headers[] = 'origin: https://www.instagram.com'; $headers[] = 'referer: https://www.instagram.com/'; $headers[] = 'x-csrftoken: '.$this->csrftoken; $headers[] = 'x-ig-app-id: 936619743392459'; $headers[] = 'x-instagram-ajax: 1'; $headers[] = 'x-requested-with: XMLHttpRequest'; $arrPostData = array(); $arrPostData['username'] = $username; $arrPostData['password'] = $password; $arrPostData['queryParams'] = '{}'; $arrPostData['optIntoOneTap'] = 'true'; $strUrl = 'https://www.instagram.com/accounts/login/ajax/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$strUrl); curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); curl_setopt($ch, CURLOPT_COOKIE, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); if($proxy !== null) { curl_setopt($ch, CURLOPT_PROXY , $proxy); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); } curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies/'.$username.'.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies/'.$username.'.txt'); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($arrPostData)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $result = curl_exec($ch); if(curl_errno($ch) !== 28 AND $result !== false AND !empty($result)) { foreach ($accounts as $account) { $user_id = $this->usr2id($account); unset($ch); $headers = $this->headers; $headers[] = 'accept: */*'; $headers[] = 'content-length: 0'; $headers[] = 'accept-encoding: gzip, deflate, br'; $headers[] = 'accept-language: en-GB,en-US;q=0.9,en;q=0.8'; $headers[] = 'content-type: application/x-www-form-urlencoded'; $headers[] = 'origin: https://www.instagram.com'; $headers[] = 'referer: https://www.instagram.com/'; $headers[] = 'x-csrftoken: '.$this->getToken($username); $headers[] = 'x-ig-app-id: 936619743392459'; $headers[] = 'x-instagram-ajax: 1'; $headers[] = 'x-requested-with: XMLHttpRequest'; $strUrl = 'https://www.instagram.com/web/friendships/'.$user_id.'/follow/'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$strUrl); curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); curl_setopt($ch, CURLOPT_COOKIE, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); if($proxy !== null) { curl_setopt($ch, CURLOPT_PROXY , $proxy); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); } curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_ENCODING, ''); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies/'.$username.'.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies/'.$username.'.txt'); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $result = curl_exec($ch); $json = json_decode($result , true); if($json['status'] !== 'fail' AND !empty($result) AND $result !== false) { $data = [ 'status' => true, 'username_followed' => $account, ]; echo json_encode($data); }else { echo $result; } } curl_close ($ch); $json_data = [ 'status' => true, 'message' => 'followed all users' ]; return json_encode($json_data); }else{ $error = curl_error($ch).PHP_EOL; curl_close ($ch); return $error; } } } C:\Users\Pot>cd C:\Users\Pot\Desktop\Insta-mass-account-creator-master C:\Users\Pot\Desktop\Insta-mass-account-creator-master>php create.php PHP Fatal error: Uncaught Error: Call to undefined function xosad\curl_init() in C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php:72 Stack trace: #0 C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php(109): xosad\InstaAccountBot->generateCsrfToken() #1 C:\Users\Pot\Desktop\Insta-mass-account-creator-master\create.php(9): xosad\InstaAccountBot->createAccount('95.110.230.142:...') #2 {main} thrown in C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php on line 72 Fatal error: Uncaught Error: Call to undefined function xosad\curl_init() in C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php:72 Stack trace: #0 C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php(109): xosad\InstaAccountBot->generateCsrfToken() #1 C:\Users\Pot\Desktop\Insta-mass-account-creator-master\create.php(9): xosad\InstaAccountBot->createAccount('95.110.230.142:...') #2 {main} thrown in C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php on line 72 C:\Users\Pot\Desktop\Insta-mass-account-creator-master>php create.php PHP Fatal error: Uncaught Error: Call to undefined function xosad\curl_init() in C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php:72 Stack trace: #0 C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php(109): xosad\InstaAccountBot->generateCsrfToken() #1 C:\Users\Pot\Desktop\Insta-mass-account-creator-master\create.php(9): xosad\InstaAccountBot->createAccount('95.110.230.142:...') #2 {main} thrown in C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php on line 72 Fatal error: Uncaught Error: Call to undefined function xosad\curl_init() in C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php:72 Stack trace: #0 C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php(109): xosad\InstaAccountBot->generateCsrfToken() #1 C:\Users\Pot\Desktop\Insta-mass-account-creator-master\create.php(9): xosad\InstaAccountBot->createAccount('95.110.230.142:...') #2 {main} thrown in C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php on line 72 C:\Users\Pot\Desktop\Insta-mass-account-creator-master>php create.php PHP Parse error: syntax error, unexpected '=' in C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php on line 72 Parse error: syntax error, unexpected '=' in C:\Users\Pot\Desktop\Insta-mass-account-creator-master\InstaAccountBot.php on line 72
  19. you are using a post method form, followed by an unnecessary redirect, to select which record to edit and then a get method form for updating the data. this is backwards. you should use get inputs to determine what will be displayed on a page and a post method form when performing an action on the server, such as updating the data. also, you can and should do all of this on one page to avoid repetition of code. the code for any page should be laid out in this general order - initialization post method form processing get method business logic - get/produce data needed to display the page html document when you display the existing records, the edit button should be a get method link with the id as part of the link. when you click one of those links, the resulting code that gets executed would query to get the existing row of data to populate the form field values, but only if the update form has never been submitted. if the update form has been submitted, you would not execute this query. the way to accomplish this 'interlocking' of the data being edited is to use an internal 'working' array variable to hold this data, then use elements in this array variable through out the rest of the code. inside the post method form processing logic, you would store a trimmed copy of the $_POST form data in this variable. at the point of querying for the initial data, if this variable is empty, you would execute the query. here are some issues with and things that will simplify the posted code - your login system should only store the user id in the session variable upon successful login, then query on each page request to get any other user information, such as the user's name, permissions. your code should check if the current logged in user is an admin before allowing access to the edit logic. when conditional 'fail' code is much shorter than the 'success' code, if you invert the condition being tested and put the fail code first, it results in clearer, cleaner code. also, since the fail code is a redirect in this case, which must have an exit/die statement to stop php code execution, you can eliminate the else {} part of the conditional test since the redirect/exit/die will stop the execution for a non-logged in user. don't copy variables to other variables for nothing. this is just a waste of typing and introduces errors. don't use multiple names for the same piece of data. whatever the actual meaning of the data is, use that name throughout the code. one such example is the staff_id value being called 'data' and at another point it is a name value. since you will be switching to use a post method form for the update operation, after you detect if a post method form has been submitted, all the form fields (except for unchecked checkbox/radio fields) will be set. there will be no need for a massive list of isset() statements. you should put the database connection code in a separate .php file, then require it when needed. you should not unconditionally echo database errors onto the web page, which will only help hackers when they internationally trigger errors. instead, use exceptions for database statement errors an in most cases let php catch and handle the exception. the exception to this rule is when inserting/updating user submitted data that can result in duplicate or out of range values, which is something that you are doing. in this case, your code should catch the exception, test if the error number is for something that your code is designed to handle, and setup a message letting the user know what was wrong with the data that they submitted. for all other error numbers, just re-throw the exception and let php handle it. the logout operation should use a post method form. any function definitions should either be in the initialization section of code or be in their own .php files that get required in the initialization section of code. your application should not use the root user without any password. instead, create a specific database user with a password with only the permissions that it needs for you application. the updateRecord function should only have two call-time parameters. an array of the input data and the database connection. the updateRecord should not contain any application specific html markup. this should be handled in the calling code. the function should only return a true or false value to the calling code. don't put external, unknown, dynamic values directly into sql query statements. you must protect against sql special characters in data values from being able to break the sql syntax, which is how sql injection is accomplished. the fool-proof way of doing this is to use prepared queries. since the mysqli extension's prepared query interface is overly complicated and inconsistent, this would be a good time to switch to the more modern and simple PDO database extension. the updateRecord function should not close the database connection. it is not the responsibility of this function to do this, only to update the recorded. the update form should populate the form field values and preselect the option that matches the initial existing data being edited, then populate/preselect using the submitted form data, as described above. any dynamic value that you output on a web page should have htmlentities() applied to it to help prevent cross site scripting. the value attribute for the select/option 1st prompt option should be an empty string. since you are putting the <label></label> tags around the form field they belong with, you don't need the for='...' and matching id='...' attributes. the post method form processing code should - detect if a post method form was submitted. keep the form data as a set in an array variable. trim all the input data as at once. after you do item #2 on this list, you can do this with one php statement. validate all the inputs, storing validation errors in an array using the field name as the array index. after the end of all the validation logic, if there are no errors, use the form data. after using the form data, if there are no errors, redirect to the exact same url of the current page to cause a get request for the page. if you want to display a one-time success message, store it in a session variable, then test, display, and clear the session variable at the appropriate location in the html document. if there are errors at step #5 or #6 on this list, the code would continue on to display the html document, where you would test for and display any errors, and redisplay the form, repopulating the field values/selected option choices with the values that are in the 'working' array variable holding the submitted form data.
  20. <?php //It's a simple program to valid age but it only print 'you can vote' despite any value I input. $age=(isset($_POST['age'])); if(isset($_POST['age'])){ if($age >=18){ echo "you can vote!!!"; }elseif($age < 18){ echo "You are not allowed to vote"; }else{ echo "enter a valid age"; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <form method="post"> <input type="text" name="age"> <input type="submit"> </form> </body> </html>
  21. Hello there, Like the title says. is there a thing that does the same job like in Windows? I have a folder that contains a file with .log extention and another one with .leases extention. And I have this command line: exec('openssl ts -verify -data /tmp/' . $log_type . '.log -in /tmp/' . $log_type . '.l*.der -token_in -CAfile /CA/cacert.pem -untrusted /CA/tsacert.pem', $result); when I run the above command line it starts varification process only on the file that has .log extention. And if I change the bold marked .log in the above command line with .leases then re run the command line then it start the same varification process but this time only on the file that has .leases extention. What I want here is that whenever I run the command line it detects both the files in the folder and start the verification process, no matter it is .log or .leases extention. So what is the thing I should write in the place of the bold marked .log to make it detect any extention? I have tried *.* or '.' or * or .l* but non of these worked Any help would be much appreciated. Thanks in advance.
  22. the processing of the submitted post method form data should have nothing directly to do with the display of any data. you should - display the form when the form is submitted, detect if a post method form has been submitted trim, then validate the form data, storing any user/validation errors in an array using the field name as the array index if there are no user/validation errors, use the form data (which could result in more user errors, such as for duplicate or out of range values) if here are no errors at this point, redirect to the exact same url of the current page to cause a get request for the page to display a one-time success message, store it in a session variable, then test, display, and clear that session variable at the appropriate location in the html document at this point, you would get any data needed to display the current page, then output it in the html document. if you want the user to be able to go to different page(s), that queries for and displays other data, provide navigation link(s) to do so.
  23. code for any page should be laid out in this general order - initialization. post method form processing. get method business logic - get/produce data needed to display the page. html document. the post method form processing should - detect if a post method form has been submitted before referencing any of the form data. keep the form data as a set in a php array variable, then operate on elements in this array variable throughout the rest of the code. trim all the input data, mainly so that you can detect if it consists of all white-space characters. validate inputs, storing validation errors in an array using the field name as the array index. after the end of the validation logic, if there are no errors, use the form data. after using the form data, if there are no errors, perform a redirect to the exact same url of the current page to cause a get request for that page. any redirect needs an exit/die statement after it to stop code execution. to display a one-time success message, store it in a session variable, then test, display, and clear the session variable at the appropriate location in the html document. if there are errors at step #5 or #6 on this list, the code would continue on to display the html document, where you would display any errors and redisplay the form, populating the form field values with any existing data. since there won't be any existing data values the first time the form is displayed, you need to address this at the point of using the values in the form. php's null coalescing operator ?? is a good choice to use here. any external, dynamic, unknown value output in a html context should have htmlentities() applied to it to help prevent cross site scripting. once you have detected that a post method form has been submitted, except for unchecked checkbox/radio fields, all form fields will be set and won't produce php errors. for checkbox/radio fields, you need to use isset() statements to test if they are set before referencing them in the form processing code. since the posted code isn't detecting if a post method form has been submitted at all before referencing the form data and isn't doing anything for item #10 on this list, you are getting unnecessary php errors. btw - if you have more than 2-3 form fields, you should use a data-driven design, where you have a data structure (database table, array) that defines the expected form fields, validation rules, and processing for each field, then dynamically validate and process the form data, rather than to write out bespoke logic for each field.
  24. no display/a blank page from a php script is usually due to fatal parse errors or fatal runtime errors. this is throwing a fatal error, since $up_user is an object, $user doesn't exist, and you are trying to get the ->wallet property of that object. the likely (since we don't know the backstory about what you are doing) syntax should be $uploader_wallet = $up_user->wallet; do you have php's error_reporting set to E_ALL and display_errors set to ON, in the php.ini on your system so that php will help you by reporting and displaying ALL the errors it detects? you will save a ton of time.
  25. Hello @gizmola @kicken Thank you for your help, i ended up using the library from barbushin. However, i have one more question. How can I "detect" which reply is associated with the original email? Steps 1) User sends email to example@example.com 2) cron job runs checks for new emails and creates new "tickets" (save to db) 3) Admin replies from the webapp 4) User replies to the admin's response 5) cron job runs detects new email -> i need somehow to map it with the existing ticket so the system won't create a new ticket again. I suspect that the "messageid" has something to do with this but i haven't found any way to take advantage of it.
×
×
  • 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.