Jump to content

Search the Community

Showing results for tags 'form'.

  • 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. Hi I want to submit the form automatically after sometime,. I have written the code , but its not redirecting/submitting. Don't know why.. Have a look Thanks <!DOCTYPE html> <html> <head> <script type="text/javascript"> setTimeout(function(){document.getElementById("exam").submit()},2000); </script> </head> <body> <?php date_default_timezone_set('Asia/Kolkata'); echo"Start Time: ".$starttime=date('H:i:s')."<br/><br/>"; $startstamp=time(); ?> <form action="inde x1.php" method="post" id="exam" name="exam"> Q1 Your Gender<br/> <input type="radio" value="male" name="gender"> Male <input type="radio" value="female" name="gender"> Female <br /><br /><br /> Q2 You Married<br/> <input type="radio" value="yes" name="marriage"> Yes <input type="radio" value="female" name="marriag e"> No <br /><br /><br /> Q3 2+2<br/> <input type="radio" value="4" name="add"> 4 <input type="radio" value="22" name="add"> 22 <input type="hidden" value="<?php echo $starttime; ?>" name="starttime"><br/> <input type="hidden" value="<?php echo $startstamp; ?>" name="startstamp"><br/> <input type="submit" name="submit"> </form> </body> </ html>
  2. Greetings all, I have been developing a comment box for my site and I ran into an issue I can't seem to figure out. In my comment box when I am logged in as an admin I want to be able to delete comments by simply clicking a button. The comments are printed out from a database using a while loop: <?php echo '<div id="commentMainTitle"><h3>Video Comments</h3></div>'; while($row = mysqli_fetch_array($results, MYSQLI_ASSOC)){ echo '<div id="commentUniqueWrap"> <div id="commentUniqueTitleMessageWrap"> <div id="commentUniqueTitle"> <h4>'. stripslashes($row['name']) .'</h4>';?> <?php if (isset($_SESSION['admin'])){?> <!--If admin add form for delete comment.--> <form enctype="multipart/form-data" action="includes/function/deletecomment.php" method="post"> <input type="hidden" name="cursect" value="<?php echo $sect1;?>" /> <input type="hidden" name="curvideored" value="<?php echo $_GET['curvideo'];?>" /> <input type="hidden" name="postID" value="<?php echo $row['id'];?>" /> <input type="submit" name="submit" value="Delete" /> <?php echo $row['id']; } echo '</div> <div id="commentUniqueMess"> <p>' . stripslashes($row['comment']). '</p> <p class="datealign">' . $row['date'] . '</p> </div> </div> </div>'; } ?> When the comments are listed out a Delete button is listed next to the commentors name. A comment is deleted however it is not the comment that is selected for deletion. Instead the last comment that was echo'd out from the while loop is deleted. Here is the script that deletes the comment: <?php if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['postID'])){ //Requires the database connection script. require $_SERVER['DOCUMENT_ROOT'] . '/mywebsite/masters/connect.php'; $qdelete = "DELETE FROM comment WHERE id ='".$_POST['postID']."' LIMIT 1"; if (!mysqli_query($connect,$qdelete)){ die('Error: ' . mysqli_error($connect)); } // Close database connection. mysqli_close($connect); // Set path for redirect. $redirect = 'http://www.mywebsite.com/myvideos.php?sect=' . $_POST['cursect'] . '&curvideo=' . $_POST['curvideored']; // Redirect to previous page. echo '<script type="text/javascript"> setTimeout(redirect, 0000); function redirect() { location.href="'.$redirect.'" } </script>'; } ?> I'm not sure what the issue is or how to go about solving it. I feel like the answer is staring me in the face but I've been looking at the code for too long and it has me at a loss. Any help would be greatly appreciated. Thank you for your time. Best Regards, Nightasy
  3. I have an html form to get a number from the user for a calculation. The first number is given. The second is entered by the user. The result is posted to the same page. BUT the resulting answer is now the first number and again the second number is entered by the user. The first code works fine for the first calculation. But the next ones still use the given number, not the result. I tried it with the else statement but couldn't get it to work right. <head> <title>Calculate</title> </head> <body> <?php $first = 2; if(isset($_POST['Calculate'])) { $second = (!empty($_POST['second']) ? $_POST['second'] : null); $total = $first+$second; print "<h2>Results</h2>"; print "The total of the two numbers: $first + $second = $total <p>"; $first=$total; } ?> <h2>Calculate</h2> <p><?php echo "First Number: $first"; ?></p> <br> <form action = "index.php" method = "POST"> <input type="hidden" name="total" value="$total" /> Second Number: <input type = "text" name = "second"><br> <input type = "submit" name = "Calculate"/> </form> </body> </html>
  4. I have my form created, and want to link it to an insert.php file where I can save data to database. Normally, I would have done it like this: <form method="post" action="insert.php"> Although, I have done my form a different way than usual to help security precautions(Reference: http://www.w3schools.com/php/php_form_complete.asp) <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Name: <input type="text" name="name" value="<?php echo $name;?>"> <span class="error">* <?php echo $nameErr;?></span> <br><br> E-mail: <input type="text" name="email" value="<?php echo $email;?>"> <span class="error">* <?php echo $emailErr;?></span> <br><br> Website: <input type="text" name="website" value="<?php echo $website;?>"> <span class="error"><?php echo $websiteErr;?></span> <br><br> Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea> <br><br> Gender: <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female">Female <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male">Male <span class="error">* <?php echo $genderErr;?></span> <br><br> <input type="submit" name="submit" value="Submit"> </form> My form's action attribute is filled with php code already, so where do I link to my insert.php file now? Can I still put a file name next to the php code that is already there? Can I do it like this, adding an onclick attribute that links to insert.php file?: <input type="submit" name="submit" value="Submit" onclick="insert.php">
  5. I'm just a beginner with PHP. I created a PHP login system. Now I want to echo the username to the logged in user on the index.php page. Here's the code I have so far. It would be great if someone could suggest a way of doing this. Thanks! login.php <?php session_start(); require_once 'classes/Membership.php'; $membership = new Membership(); // If the user clicks the "Log Out" link on the index page. if(isset($_GET['status']) && $_GET['status'] == 'loggedout') { $membership->log_User_Out(); } // Did the user enter a password/username and click submit? if($_POST && !empty($_POST['username']) && !empty($_POST['pwd'])) { $response = $membership->validate_User($_POST['username'], $_POST['pwd']); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Login</title> <link rel="stylesheet" type="text/css" href="css/default.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script> <script type="text/javascript" src="js/main.js"></script> </head> <body> <div id="login"> <form method="post" action=""> <h2>Login <small>enter your credentials</small></h2> <p> <label for="username">Username: </label> <input type="text" name="username" /> </p> <p> <label for="pwd">Password: </label> <input type="password" name="pwd" /> </p> <p> <input type="submit" id="submit" value="Login" name="submit" /> </p> </form> <?php if(isset($response)) echo "<h4 class='alert'>" . $response . "</h4>"; ?> </div><!--end login--> </body> </html> index.php (the page that the user is redirected to after logging in) <?php require_once 'classes/Membership.php'; $membership = New Membership(); $membership->confirm_Member(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/default.css" /> <!--[if lt IE 7]> <script type="text/javascript" src="js/DD_belatedPNG_0.0.7a-min.js"></script> <![endif]--> <title>Untitled Document</title> </head> <body> <div id="container"> <p> You have logged in. </p> <a href="login.php?status=loggedout">Log Out</a> </div><!--end container--> </body> </html> membership.php <?php require 'Mysql.php'; class Membership { function validate_user($un, $pwd) { $mysql = New Mysql(); $ensure_credentials = $mysql->verify_Username_and_Pass($un, md5($pwd)); if($ensure_credentials) { $_SESSION['status'] = 'authorized'; header("location: index.php"); } else return "Please enter a correct username and password"; } function log_User_Out() { if(isset($_SESSION['status'])) { unset($_SESSION['status']); if(isset($_COOKIE[session_name()])) setcookie(session_name(), '', time() - 1000); session_destroy(); } } function confirm_Member() { session_start(); if($_SESSION['status'] !='authorized') header("location: login.php"); } } mysql.php <?php require_once 'includes/constants.php'; class Mysql { private $conn; function __construct() { $this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database.'); } function verify_Username_and_Pass($un, $pwd) { $query = "SELECT * FROM users WHERE username = ? AND password = ? LIMIT 1"; if($stmt = $this->conn->prepare($query)) { $stmt->bind_param('ss', $un, $pwd); $stmt->execute(); if($stmt->fetch()) { $stmt->close(); return true; } } } } Thanks a lot!
  6. I have HTML form linked with MYSQL database via PHP. If I submit this form, values will save in MYSQL database but not load into form. I see there old values so I have to refresh page to see desired values. I would like to see new values at form submission. *** I solved it when i put header("Location: edit.php?page=zakladni_udaje.php") ( = same as form action) on THE END OF ISSET form submit, it worked fine but I cant print message about success or fail after submiting. <?php ob_start(); session_start(); ?> <form action="edit.php?page=zakladni_udaje.php" method="post"> <?php $con = mysql_connect("localhost", "mairichovci", "ak41801") or die("Nelze se připojit k MySQL: " . mysql_error()); mysql_select_db("mairichovci") or die("Nelze vybrat databázi: ". mysql_error()); if($_SESSION['id'] > 0){ $profil_pomocny = mysql_query("SELECT * from profil where id=".$_SESSION['id'], $con); $profil = MySQL_Fetch_Assoc($profil_pomocny); $or_pomocny = mysql_query("SELECT * from osobaky where id=".$_SESSION['id'], $con); $or = MySQL_Fetch_Assoc($or_pomocny); $zobraz_pomocny = mysql_query("SELECT * from zobraz where id=".$_SESSION['id'], $con); $zobraz = MySQL_Fetch_Assoc($zobraz_pomocny); $id = $_SESSION['id']; $fce = $_POST['fce']; $email = $_POST['email']; $tel = $_POST['tel']; $position = $_POST['position']; $home = $_POST['home']; $omne = $_POST['omne']; if( isset ($_POST['uloz'])): $sql = "UPDATE profil SET fce = '$fce', email = '$email', tel = $tel, position = '$position', home = '$home', omne = '$omne' WHERE id = '$id'"; if (!mysql_query($sql)): die('Chyba: ' . mysql_error()); else: $message = "Údaje byly uloženy"; endif; mysql_close(); endif; echo '<div id="message">'.$message.'</div>'; ?> <table style = "margin-top: -1px" align="center" class="tabulka"> <tr> <td width="40%">Funkce:</td> <td><input type="text" name="fce" placeholder = "(např. Běžec - 800m, 1500m a delší)" maxlength="35" size="48" value="<?php echo $profil['fce']; ?>" class="vstupy" style="width: 350px"></td> </tr> <tr> <td></td> <td><input type="submit" name="uloz" value="Ulož" class="tlacitko2" style="width: 350px; margin-left:4px"></td> </tr> </table> </form> <?php } else{header("Location: prihlas.php");} ob_end_flush(); ?> Can anybody help me? Thanks in advance
  7. I have a list of students entered into a mysql table using the following fields: id, name, surname, address, towncode, streetcode, Another two tables has been designed so to normalize the schema: One is the Streets table streetcode, streetname, towncode .. and the other one is towns with the following fields: towncode, townname Now i need to design a form using php to filter students depending on the town (I select using the SELECT element of a form) , and as well on the street (I select using the SELECT element of a form) which fall under that town. Can someone help me out with this issue. Sorry but I am new to PHP!!!!!!!
  8. What I am aiming to do, with some help as I am new to PHP.. Is that I want to create a shortcode for this plug in so that I can use the shortcode in a selected footer area or post. Thanks for your time in advanced.. really need help. This is the plugin's only file. <?php /* Plugin Name: Constant Contact Widget Plugin URI: Description: Constant Contant widget for submitting email address Version: 1.5 Author: Author URI: License: GPL2 */ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ if (class_exists('WP_Widget')) add_action('widgets_init','sf_constantcontact_widget'); if (is_admin()) { add_action('wp_ajax_nopriv_constantcontactadd','sf_constantcontact_ajax'); add_action('wp_ajax_constantcontactadd','sf_constantcontact_ajax'); add_action('admin_menu','sf_constantcontact_menu'); add_action('admin_init','sf_constantcontact_admin'); } function sf_constantcontact_ajax() { ob_clean(); $set=get_option('sf_mcc'); if (empty($set['log'])||empty($set['pwd'])) echo __('Plugin settings incomplete'); else if (empty($_POST['grp'])) echo __('No contact list specified'); else if (empty($_POST['eml'])) echo __('No email provided'); else { $rsp=wp_remote_get("http://ccprod.roving.com/roving/wdk/API_AddSiteVisitor.jsp?" .'loginName='.urlencode($set['log']) .'&loginPassword='.urlencode($set['pwd']) .'&ea='.urlencode($_POST['eml']) .'&ic='.urlencode($_POST['grp']) .(empty($_POST['fnm'])?'':('&First_Name='.urlencode(strip_tags($_POST['fnm'])))) .(empty($_POST['lnm'])?'':('&Last_Name='.urlencode(strip_tags($_POST['lnm']))))); if (is_wp_error($rsp)) echo __('Could not connect to Constant Contact'); else { $rsp=explode("\n",$rsp['body']); if (intval($rsp[0])) echo count($rsp)>1?$rsp[1]:(intval($rsp[0])==400?__('Constant Contact username/password not accepted'):__('Constant Contact error')); } } die(); } function sf_constantcontact_widget() { register_widget('sf_widget_constantcontact'); } function sf_constantcontact_admin() { register_setting('sf_constantcontact_group','sf_mcc','sf_constantcontact_validate'); } function sf_constantcontact_menu() { add_options_page('Constant Contact Settings','Constant Contact','manage_options','sf_constantcontact_options','sf_constantcontact_options'); } function sf_constantcontact_options() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } echo '<div class="wrap"><h2>Constant Contact Settings</h2>' .'<form action="options.php" method="post">'; settings_fields("sf_constantcontact_group"); $set=get_option('sf_mcc'); echo '<table class="form-table">' .'<tr valign="top"><th scope="row">Constant Contact Username</th><td><input type="text" name="sf_mcc[log]" value="'.(isset($set['log'])?$set['log']:'').'" /></td></tr>' .'<tr valign="top"><th scope="row">Constant Contact Password</th><td><input type="password" name="sf_mcc[pwd]" value="'.(isset($set['pwd'])?$set['pwd']:'').'" /></td></tr>' .'</table>' .'<p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="Save"></p>' .'</form></div>'; } function sf_constantcontact_validate($in) { $in['log']=trim($in['log']); $in['pwd']=trim($in['pwd']); return $in; } if (class_exists('WP_Widget')) { class sf_widget_constantcontact extends WP_Widget { public function __construct() { parent::__construct('sf_widget_constantcontact','Constant Contact',array('description'=>'Email subscription widget')); } public function widget($args,$instance) { extract($args); $id=str_replace('-','_',$this->id); $title=apply_filters('widget_title',$instance['title']); if (empty($title)) echo str_replace('widget_sf_widget_constantcontact','widget_sf_widget_constantcontact widget_no_title',$before_widget); else echo $before_widget; if (!empty($title)) echo $before_title.$title.$after_title; echo '<div id="'.$id.'_form">' .(empty($instance['txt'])?'':('<p>'.$instance['txt'].'</p>')) .'<input type="hidden" name="grp" value="'.esc_attr($instance['grp']).'" />' .(empty($instance['nam']) ?('<input type="text" name="eml" class="input" placeholder="'.__('Email').'" />') :('<label for="fnm">'.__('First Name').'</label><input type="text" name="fnm" class="input" />' .'<label for="lnm">'.__('Last Name').'</label><input type="text" name="lnm" class="input" />' .'<label for="eml">'.__('Email').'</label><input type="text" name="eml" class="input" />')) .'<input type="submit" value="'.esc_attr($instance['btn']).'" onclick="'.$id.'_submit(this.parentNode)" />' .'</div>' .'<script>function '.$id.'_submit(n){' .'for(var i=n.firstChild,eml=false,val=["action=constantcontactadd"];i;i=i.nextSibling)if(!(i.nodeName!="INPUT"||!i.name)){if(!(i.name!="eml"||!i.value)) eml=true;val.push(i.name+"="+encodeURIComponent(i.value));}' .'if(!eml){alert("'.__('Please enter an email address').'");return;}' .'var xml=new XMLHttpRequest();' .'xml.open("POST","'.admin_url('admin-ajax.php').'",true);' .'xml.setRequestHeader("Content-type","application/x-www-form-urlencoded");' .'xml.onreadystatechange=function(){if(this.readyState==4){if(this.status==200){if(this.responseText) alert(this.responseText); else '.(preg_match('/^\/\/|^http:\/\/|^https:\/\//i',$instance['msg'])?('setTimeout(\'window.location="'.esc_attr($instance['msg']).'";\',100);'):('n.innerHTML="'.esc_attr($instance['msg']).'";')).'} else alert(this.statusText);}};' .'xml.send(val.join(String.fromCharCode(38)));' .'}</script>'; echo $after_widget; } public function update($new_instance,$old_instance ) { $instance=$old_instance; $instance['title']=strip_tags($new_instance['title']); $instance['txt']=trim($new_instance['txt']); $instance['btn']=trim($new_instance['btn']); $instance['grp']=trim($new_instance['grp']); $instance['msg']=trim($new_instance['msg']); if (!empty($new_instance['nam'])) $instance['nam']=1; else unset($instance['nam']); return $instance; } public function form($instance) { $instance=wp_parse_args($instance,array('title'=>'','txt'=>'','btn'=>'Subscribe','log'=>'','pwd'=>'','grp'=>'General Interest','msg'=>'Thank you, you\'ve been added to the list!','nam'=>'')); echo '<p><label for="'.$this->get_field_id('title').'">Title:</label><input class="widefat" id="'.$this->get_field_id('title').'" name="'.$this->get_field_name('title').'" type="text" value="'.esc_attr($instance['title']).'" /></p>' .'<p><label for="'.$this->get_field_id('txt').'">Description:</label><input class="widefat" id="'.$this->get_field_id('txt').'" name="'.$this->get_field_name('txt').'" type="text" value="'.esc_attr($instance['txt']).'" placeholder="description" /></p>' .'<p><label for="'.$this->get_field_id('btn').'">Button Text:</label><input class="widefat" id="'.$this->get_field_id('btn').'" name="'.$this->get_field_name('btn').'" type="text" value="'.esc_attr($instance['btn']).'" placeholder="button text" /></p>' .'<p><label for="'.$this->get_field_id('grp').'">Contact List Name:</label><input class="widefat" id="'.$this->get_field_id('grp').'" name="'.$this->get_field_name('grp').'" type="text" value="'.esc_attr($instance['grp']).'" /></p>' .'<p><label for="'.$this->get_field_id('msg').'">Success Message/URL:</label><input class="widefat" id="'.$this->get_field_id('msg').'" name="'.$this->get_field_name('msg').'" type="text" value="'.esc_attr($instance['msg']).'" /></p>' .'<p><input type="checkbox" id="'.$this->get_field_id('nam').'" name="'.$this->get_field_name('nam').'" value="1"'.(empty($instance['nam'])?'':' checked').'> <label for="'.$this->get_field_id('nam').'">Ask for first and last name</label></p>'; } }} ?>
  9. Hello, I am writing an app and I am trying to include a feedback form. I have the form and php script written but it isn't working. Can somebody take a look at it and see if I am missing something? This is my first try at writing PHP. The form will submit via email and have five sections: name, email, city, what and comments. Submit to List Name: Email: City: What: Comments: The form shows up fine but it is the PHP I'm having trouble with. Below is the code I have so far for the HTML form and PHP file. I would like an email of the form to go to tim@akluk.com and another screen to pop up that says "Thank You" with a close button to take the viewer back to the home page. I appreciate any help I can get on getting this form to work. I am currently using Dreamweaver as my editor and I modified some code I found here: http://www.freecontactform.com/email_form.php. I am also referencing an O'Reilly book called Learning PHP, MySQL, JavaScript, & CSS. Thanks for your help! submit.htmlsubmit.php // Form HTML // "submit.html" <!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>Submit to List</title> <meta name="viewport" content="width=device-width,user-scalable=no"> <link rel="stylesheet" href="jquery.mobile-1.0.css" /> <link href="jQueryAssets/jquery.ui.core.min.css" rel="stylesheet" type="text/css"> <link href="jQueryAssets/jquery.ui.theme.min.css" rel="stylesheet" type="text/css"> <link href="jQueryAssets/jquery.ui.button.min.css" rel="stylesheet" type="text/css"> <script src="jquery.js"></script> <script src="script.js"></script> <script src="jquery.mobile-1.0.js"></script> <script src="jQueryAssets/jquery-1.8.3.min.js" type="text/javascript"></script> <script src="jQueryAssets/jquery-ui-1.9.2.button.custom.min.js" type="text/javascript"></script> </head> <body> <div data-role="dialog"> <div data-role="header"> <h1>Submit to List</h1> </div> <div data-role="content"> <form action="submit.php" method="post" data-transition="none"> <div data-role="fieldcontain"> <label for="name">Name:</label> <input type="text" name="name" id="name" value="" required /> </div> <div data-role="fieldcontain"> <label for="email">Email:</label> <input type="email" name="email" id="email" value="" required /> </div> <div data-role="fieldcontain"> <label for="City">City:</label> <input type="text" name="city" id="city" value="" required /> </div> <div data-role="fieldcontain"> <label for="what">What:</label> <input type="text" name="what" id="what" value="" required /> </div> <div data-role="fieldcontain"> <label for="comments">Comments:</label> <textarea cols="40" rows="8" name="comments" id="comments"></textarea> </div> <input type="submit" value="Send" data-theme="a"> </form> </div> </div> </body> </html> // PHP Code // "submit.php" <!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>Submission</title> <meta name="viewport" content="width=device-width,user-scalable=no"> <link rel="stylesheet" href="jquery.mobile-1.0.css" /> <script src="jquery.js"></script> <script src="script.js"></script> <script src="jquery.mobile-1.0.js"></script> </head> <body> <div data-role="dialog"> <div data-role="header"> <h1>Submit to List</h1> </div> <div data-role="content"> <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "tim@akluk.com"; $email_subject = "List Suggestion"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['city']) || !isset($_POST['what']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['name']; // required $email_from = $_POST['email']; // required $city = $_POST['city']; // required $what = $_POST['what']; // required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$name)) { $error_message .= 'The Name you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$city)) { $error_message .= 'The City you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$what)) { $error_message .= 'What you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Name: ".clean_string($name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "City: ".clean_string($city)."\n"; $email_message .= "What: ".clean_string($what)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n". 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> Thanks for your suggestion. <a data-role="button" data-inverse="true" href="index.html">Close</a> </div> </div> </body> </html>
  10. Hey everyone, I wrote a Caesar cipher (a script where, given a message, the letters in the message are shifted x number of places; e.g. A => D, B => E, C => F, X => A, Y => B, Z => C, etc.). It works but it shifts all ASCII characters. I want to exclude characters that are not A-Z or a-z (outside the ASCII values of 65 - 90 and/or 97 - 122) so that spaces, punctuation, numbers all remain the same instead of shifting as well. Here's the form on index.html <form class="form-inline" role="form" method="post"> <div class="table-responsive"> <table> <tr class="tr_top"> <td class="td_top"><textarea class="form-control" rows="4" name="msg" placeholder="Your message here." onfocus='this.select()'><?php require ('encode.php'); require ('decode.php'); if (isset($_POST['encode'])) { echo $encstring; } elseif (isset($_POST['decode'])) { echo $decstring; } ?></textarea></td> </tr> <tr class="tr_mid"> <td class="td_mid"><input type=text class="form-control input_mid" name="offset" value="<?php if (isset($_POST['encode']) || isset($_POST['decode'])) { echo htmlspecialchars($_POST['offset']);} ?>" placeholder="Enter a number." pattern="[0-9]{0,3}" oninvalid="setCustomValidity('Please enter a number between 1 and 999.')" oninput="setCustomValidity('')"></td> </tr> <tr class="tr_bottom"> <td class="td_bottom"> <input class="input_bottom btn btn-default submit" type="submit" name="encode" value="Encode"> <input class="input_bottom btn btn-default submit" type="submit" name="decode" value="Decode"> <input class="input_bottom btn btn-default" type="button" value="Clear"</td> </tr> </table> </div><!-- close table-responsive --> </form> <?php //encode require ('encode.php'); if (isset($_POST['encode'])) { echo "<p>Original message:</p>"; echo "<p class='string ital'>" . $string . "</p>"; echo "<p>Encoded message:</p>"; echo "<p class='string ital'>" . $newstring . "</p>"; } //decode require ('decode.php'); if (isset($_POST['decode'])) { echo "<p>Encoded message:</p>"; echo "<p class='string ital'>" . $string . "</p>"; echo "<p>Decoded message:</p>"; echo "<p class='string ital'>" . $newstring . "</p>"; } ?> and here is encode.php <?php $string = $_POST['msg']; $newstring = $string; $sp = $_POST['offset']; for ($i=0; $i < strlen($string); $i++) { $ascii = ord($string[$i]); for ($j=0; $j < $sp; $j++) { if ($ascii == 90) { //uppercase bound $ascii = 65; //reset back to 'A' } else if ($ascii == 122) { //lowercase bound $ascii = 97; //reset back to 'a' } else { $ascii++; } } $newstring[$i] = chr($ascii); $encstring = $newstring; } ?> Any help would be appreciated as I can't figure it out. If you want to see it in action it's here.
  11. <?php if(isset($_POST['txtEmail'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "xyz@abc.com"; $email_subject = "Subject"; $email_from = "abc@xyz.com"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below."; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['txtName']) || !isset($_POST['txtEmail']) || !isset($_POST['txtAddress']) || !isset($_POST['txtContact']) || !isset($_POST['txtUpload'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $name = $_POST['txtName']; // required $email = $_POST['txtEmail']; // required $address = $_POST['txtAddress']; // required $contact = $_POST['txtContact']; // not required $upload = $_POST['txtUpload']; // required $email_message = "Form Details are below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "Full Name: ".clean_string($name)."\n\n"; $email_message .= "Address: ".clean_string($address)."\n\n"; $email_message .= "Email ID: ".clean_string($email)."\n\n"; $email_message .= "Contact No.: ".clean_string($contact)."\n\n"; $email_message .= "File: ".clean_string($upload)."\n\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> i am a rookie in php I got 2 problems 1) I am not able to insert a code for file upload in the above code. 2) In other type of form (with different textfields).i have a text (it is like a disclaimer) in the html form which i want it in email too.
  12. Hi, I want to create a place to receive large files from my customers. This is how it supposed to look like: http://sextantecontratos.com.br/restrito.php It should be able to let user upload files <30MB and with specifc extensions shown. However, I'm not able to make it fully working. I did get file upload succesfully thru coding below, which means my server is ok. <html> <body> <form enctype="multipart/form-data" action="teste.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="32000000"> Send this file: <input name="userfile" type="file"> <input type="submit" value="Send File"> </form></body></html> and <?php $uploaddir = './'; $uploadfile = $uploaddir . $_FILES['userfile']['name']; print "<pre>"; if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])) {print "TESTE OK (arquivo valido e carregado com sucesso). Dados:\n"; print_r($_FILES);} else {print "ERRO NA OPERAÇÃO. Dados:\n"; print_r($_FILES);} print "</pre>"; ?> But when I face the "restrito.php" code, I can't make it work... Can anyone please help?
  13. i dont want to use "str_repeat". could someone give me some ideas how to make my own function without using str_repeat i am wanting the user to enter 4 numbers into 4 input boxes for example input 1 : 6 input 2 : 5 input 3 : 4 input 4 : 3 answer 666666 55555 4444 333
  14. Form output: Description: vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv textarea coding on input form: <textarea rows="10" name="description" cols="70"><?php echo set_value('description'); ?></textarea><br> coding on output: <td class="dt2 dt0"><?php echo $this->lang->line('Description');?>:</td> <td class="dt2"><?php echo nl2br($project->description); ?></td> How can I get the line breaks in the output? Your help would be appreciated. Thanks
  15. I'm trying to set up what I thought would be an easy form with button. I want to get the registration information out of the form when someone fills it out and pays. Instead, clicking the button leads to a mess of bad information at the top of the PayPal page. I think I'm missing something that pulls the data out of the form when someone registers. Looking at some examples online, someone who has done this before could probably fix my code in a few minutes. I thought the HTML skills learned I learned in the mid/late 90s were adequate for this. Sorry for the wall of code, but I provided it below. I've spent hours to get to this point and made a bunch of changes from some other forums and it still drops and error. http://www.lifeatpathway.com/what-s-happening/mukti-5k-registration <form action="https://www.paypal.com/cgi-bin/webscr" method="post" name="mukti5k" id="5k" onsubmit="this.target='paypal'; return UpdateForm(this);" > <table> <tbody> <tr> <td>First name:</td> </tr> <tr> <td><input type="hidden" name="on0" value="First Name" /> <input type="text" name="os0" size="30" /></td> </tr> <tr> <td>Last name:</td> </tr> <tr> <td><input type="hidden" name="on1" value="Last Name" /> <input type="text" name="os1" size="30" /></td> </tr> <tr> <td>Address:</td> </tr> <tr> <td><input type="hidden" name="on2" value="Address" /> <input type="text" name="os2" size="30" /></td> </tr> <tr> <td>City:</td> </tr> <tr> <td><input type="hidden" name="on3" value="City" /> <input type="text" name="os3" size="20" /></td> </tr> <tr> <td>State:</td> </tr> <tr> <td><input type="hidden" name="on3" value="State" /> <input type="text" name="os3" size="2" /></td> </tr> <tr> <td>Zip:</td> </tr> <tr> <td><input type="hidden" name="on3" value="Zip" /> <input type="text" name="os3" size="10" /></td> </tr> <tr> <td>Phone:</td> </tr> <tr> <td><input type="hidden" name="on3" value="Phone" /> <input type="text" name="os3" size="14" /></td> </tr> <tr> <td>Email:</td> </tr> <tr> <td><input type="hidden" name="on3" value="Email" /> <input type="text" name="os3" size="30" /></td> </tr> <tr> <td>Age:</td> </tr> <tr> <td><input type="hidden" name="on3" value="Age" /> <input type="text" name="os3" size="2" /></td> </tr> <tr> <td>Gender:</td> </tr> <tr> <td><input type="radio" name="gender" value="male" /> Male <input type="radio" name="gender" value="female" /> Female</td> </tr> <tr> <td>Race:</td> </tr> <tr> <td><input type="radio" name="race" value="5k" /> Mukti 5K <input type="radio" name="race" value="1m" /> Mukti 1 Mile Fun Walk</td> </tr> <tr> <td><input type="hidden" name="on1" value="Shirt Size" />Shirt Size: </td> </tr> <tr> <td><input type="radio" name="shirt" value="ys" /> Youth Small <input type="radio" name="shirt" value="ym" /> Youth Medium <input type="radio" name="shirt" value="yl" /> Youth Large <br /><input type="radio" name="shirt" value="as" /> Adult Small <input type="radio" name="shirt" value="am" /> Adult Medium <input type="radio" name="shirt" value="al" /> Adult Large <input type="radio" name="shirt" value="axl" /> Adult XL <input type="radio" name="shirt" value="axxl" /> Adult XXL</td> </tr> <tr> <td colspan="2" align="center"> <div> </div> <div><input type="checkbox" name="agree" value="agree_terms" /> By checking this box, I, intending to be legally bound for myself, my heirs, my executors and administrators, waive, release and discharge any and all rights and claims which I may have or which hereafter may arise from all claims of damage, actions, injury or death received in any manner before, during or after participation in the 2014 Pathway Church Mukti 5K and 1 Mile Run/Walk on Saturday, May 10, 2014. I shall abide by all decisions of race officials as final. I also release the sponsoring organizations and individuals from all legal responsibility or liability for the use of any photographs involving me for the purpose of advertising or reporting.</div> </td> </tr> </tbody> </table> <input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_paynowCC_LG.gif" alt="Register Now" align="middle" /> <input type="hidden" name="cmd" value="_xclick" /> <input type="hidden" name="business" value="mikejohnston5@gmail.com" /> <input type="hidden" name="return" value="http://www.lifeatpathway.com" /> <input type="hidden" name="currency_code" value="USD" /> <input type="hidden" name="bn" value="PP-ShopCartBF" /></form>
  16. $formhtml="<form action="sometext" method="POST">"; Please this is driving me nuts how can i remove an action="sometext" or action="" from a form?
  17. I would appreciate some assistance. I am very green when it comes to programming so please excuse my lack of understanding / number of questions I have two sites for a client, both of which use a similar form structure, both of which are built in PHP. The form is a quotation request form with 3 pages on it, the last of which has an area for the customer to enter their contact details and also has a 'comments' section for them to submit specific comments regarding their enquiry. When a customer submits the quote, and email is sent to the company and it specifies the contact details, what the enquiry was in relation to, and the location. Here however is the issue. On one of the sites, anloffshorecontainers.com.au there is no issue. Comments submitted are transferred in the emai. The other site however, anlcontainers.com.au sends the details to the client capturing everything except whatever is included in the 'comments' box on the form. I compared the code between the two sites for this form, and as I said I am not a programmer, but found the only difference was that on the form that was working (on the attached coding titled 'OFFSHORE') there is the code: id="comment" inserted within the relevant section of code, however this is missing off the coding for the site that has the issue (called 'MAIN' on the attached). I thought perhaps this was the issue so added this id="comment" into the code on the php template in WordPress and it has made no difference. My questions: 1. How do I fix this so that the comments are sent in the email to the client for the site having issues? 2. For my own learning, what does id="comment" mean? I assumed this picked up text in the comments section and transferred with the email, however I may be completely off track. I have attached the relevant code pieces I refer to, along with the full code for the page on which we are having issues where this id="comments" is missing on line 223. Thanks Will Issues with Comments on form for sites.txt
  18. Hello! Second post here. I'm new to PHP and have an idea of what needs to be done, but im not sure the best way to impliment it. Basically im looking for direction on whether I should use JS, AJAX, Jquery, or something else. from browsing around im guessing its going to be a combination of AJAX and Jquery to get this accomplished. Please advise on the best method to acomplish this. Thanks =) The user needs to populate txtAddr and hit btnGen. The function will then confirm txtAddr is equal to a variable. If it is equal, populate other 2 text fields (txtKey & txtDest) with predefined variables. <form action="frmGen" method="post"> <input name="txtAddr" type="text"> <!-- User enters text here -- Confirm txtAddr.text = $VarAddr -- If True, continue. If False, display DIV message --> <input name="txtDest" type="text"> <!-- Text field is filled with value from server/SQL when btnGen is pressed--> <input name="txtKey" type="text"> <!-- Text field is filled with value from server/SQL when btnGen is pressed--> <input name="btnGen" type="button"> <!-- assuming txtAddr is True, display strings in 2 text fields above & store all values from 3 text boxes in SQL --> </form>
  19. Hi everyone. So I have a HTML form using PHP to pull a column from a MySQL table. However, I have a second field in my form that I want to pull a second row of data from that same table, when the first row is selected. Example DB Table: id=1 <---This is Primary Key name=ItemA <---This is the data that shows in the drop down list sku=1234 <---This is the data I want to throw into $_POST['sku'] when something is selected in name Here is the code I currently have for my form: <form method="POST" action="submitadd.php" /> <table id="add"> <tr> <td class="headings"><b>Species:</b></td> <td><select name=species:> <option value="select">Choose a Species</option> <?php $prodquery="SELECT name FROM products ORDER BY name ASC"; $result=mysqli_query($con,$prodquery) or die(mysqli_error($con)); while ($row = mysqli_fetch_array($result)) { echo "<option value='" . $row['name'] . "'>" . $row['name'] . "</option>"; } ?> </select> </td> </tr> <tr> <td class="headings"><b>SKU:</b></td> <td><input type="text" name="sku" value="<?php echo $row['sku']; ?>" readonly="readonly" size="35" /></td> </tr> Currently, the SKU field is a readonly field but I want it to pull data from the database when someone makes a select on the dropdown above. I assume this will require javascript? I have no experience with javascript, and was hoping someone could help me out or at least point me in the right direction. I don't have a clue how to search for this on Google. Thanks.
  20. Hello. I have a php form processor that I'm used to working with but I need someone to make some modifications for me. A. Right now, if a required field is missing, the processor tells the user that the field is required and asks them to press the "back" button and fill in that field. This works fine, however, if more than one required field is missing it only tells the user that one field at a time, so they have to keep hitting the back button for each missing field. If possible, I would like the processor to list ALL of the missing fields at one time. B. After the form is successfully submitted, it gives a generic "thank you" page and lets the user know they can close the window. I would like the form to redirect to a separate page so that I can modify the "thank you" page content for each form. I will send the code if you are interested. Thanks in advance for any help. I'm willing to trade this work for a graphic design, logo design, business cards, or free (legitimate) website hosting, otherwise let me know how much it will cost to have the processor modified.
  21. Hi everyone. I have another question, which will hopefully be the last piece to get my application going. I have a MySQL table with an enum field, with a few values (Value1, Value2, Value3, Value4). I have a HTML form that is pulling over fields from the same table, but those other fields are varchar fields. I'm wanting to create a drop down box which is dynamically populated with those enum values, and that defaults to the currently selected field. I have found a few examples of this, but they all seem to be deprecated mysql_* code, whereas I'm using mysqli_* throughout. I'm fairly new to PHP, and I have never written a function before. I figure something like this would be out there somewhere, but I haven't been able to find an example here at PHPFreaks, nor on various other forums. Here are some examples of what I have found using mysql_*: http://www.barattalo.it/2010/01/19/php-to-get-enum-set-values-from-mysql-field/ http://stackoverflow.com/questions/3715864/displaying-mysql-enum-values-in-php http://www.larryullman.com/forums/index.php?/topic/916-use-data-type-enum-for-form-drop-down-options/ http://www.pcserviceselectronics.co.uk/php-tips/enum.php I just don't know where to start with creating this function. I need to use this 3 times, or 2 different fields, which is why I assumed a function would be the best way to go. Thanks for any help!
  22. I have site that was written as a custom job several years ago. Part of the site uses authorize.net allowing new customers to register and buy products online. It is all php/mysql. There is no framework involved. Most of the code is 3 - 5 years old. I am starting to go through it as we are migrating it to a new hosting platform and I"m realizing there are some changes that need to be made. One glaring annoyance is that the buynow.php page which is where people register and buy stuff has a link to enter a coupon code. The link takes the user to a new page with a simple form to enter a coupon code. Once the code is entered and the user hits submit, the code is validated and if all is well, the user is taken back to the buynow.php page. The only problem is that the user has entered a bunch of data (name, address, email etc..) and then got to the coupon code link, clicked it, came back to buynow.php, and the form is empty again. What is the best way to keep the form data saved and repopulate the form with that data when the coupon code is entered? I think it may be better to change the coupon code logic so it happens on the same buynow.php page, and updates the price when the user hits and "apply coupon" button. I am a php novice - I have done programming before but it's been a while and it certainly wasn't php. I've been through lots of php tutorials and read a lot about it. I'm hoping I can get some guidance here so I can make these changes myself and turn it into a learning experience. Thanks Patrick buynow.php
  23. Hey all, I'm desperately trying to find an answer to this issue. I pretty much can't go on holiday until I resolve this one damn thing.. so if you can nail it for me, you're quite literally buying me some well deserved downtime and I'll be super stoked!! http://stackoverflow.com/questions/20810551/filling-a-text-field-in-a-php-form-field-with-passed-url-data Thanks. B
  24. Hello everyone, I am trying to create a minicab booking form with mysql I have created following tables category (this where the locations categorised like Airport, Postcode, Stattions etc) Locations (this is where the pick up address and destination address will be choosed from) Journeys (This is where the journey pick up, destination, vehicle and the price will be stored.) What I am trying to achieve is, after storing all the information into tables, visitors will be schoosing a pick up address and destination so they can get a price. At the moment addresses are loaded from LOCATIONS table into both fields. See picture below: The problem with it is, the locations are shown regardles if there is a journey with price with it or not. What I want is to fetch only the data from JOURNEYS with price. Could anyone help me with this?
  25. I can't seem to see the problem with my success and not success form below. The form is sent successfully but keep outputting oops try again <?php if ($success) { $message = "Message sent succesfully! Thank you."; } else { $message = "Oops! Try again!"; } echo '<div id="message">'.$message.'<div id="close-button"></div></div>'; ?>
×
×
  • 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.