Search the Community
Showing results for tags 'forms'.
-
Hello Phreaks and Geeks, I hope the week has seen you all well and you're all gearing up for a great weekend. I've had to take up relearning of js and new learning of ajax recently and have a simple question I can't seem to resolve. Take this sample form here -> <form action="", method="post", onsubmit="return submitData(this)"> First Name: <br> <input type="text" name="firstname"> <br> Last Name: <br> <input type="text" name="lastname"> <br> Age: <br> <input type="text" name="age"> <br> <input type="submit" id="buttonOne" value="Submit"> </form> I've been passing the morning familiarizing myself with XMLHttpRequest() and FormData() classes and have the following super simple snippets function submitData(fdata) { var formData = new FormData(fdata); for (var pair of formData.entries()) { console.log( pair[0] + ' - ' + pair[1] ); } } AND var formData = new FormData(); formData.append('key_1', 'First value'); formData.append('key_2', 'Second value'); formData.append('key_3', 'Third value'); for (var pair of formData.entries()) { console.log( pair[0] + ' - ' + pair[1] ); } The bottom one, where I create the form data programatically displays the data in console properly. The top one where I try to pull the data from the form does not work. Could someone break down what is happening here and point out the errors in my thinking please. Thank you
-
Hi - I want to add to a php form a button which will open a pop-up window with records (names of people) and associated radio buttons. On click on respective name's radio button and SUBMIT, parent form textbox is populated. (list of names will be dynamically be selected fro MySQL table). Any suggestions? Many thanks! IB.
-
Hi, So I am currently making a real estate site for my class at school but I am having a tiny issue with the listing display page. So what I want to do is show a bunch of listing that the agent owns on their dashboard which I have already done. Now I have two links one to update the listing and one to view the listing. Now what I am trying to do is when the view listing link is clicked it will take the user to the listing-display page and then I want it to display all the information for the listing that the link was clicked under. But i cannot for the life of me figure out how to do that! This is currently the code for the dashboard where you only view the listing headline <?php // If the session was never set with a user id $output = ''; $conn = db_connect(); if($_SESSION['userType'] != AGENT) { $_SESSION['RedirectError'] = "You were not logged in as an Agent<br/>"; header("Location:login.php"); } if (isset($_GET["page"])) { $page = $_GET["page"]; $index = ($page -1) * IMAGE_LIMIT; } else { $page=1; $index = 0; } ?> <!-- start of main page content --> <div class="container" style="margin-top: 2em;"> <h2>Dashboard</h2> <p>Welcome back <?php echo $_SESSION['userId']; ?> you last logged in on <?php echo $_SESSION['last_access']; ?></p> <h4>Your Listings</h4> <?php $sql = "SELECT listing_id FROM listings WHERE user_id = '".$_SESSION['userId']."' AND status = 'o' ORDER BY listing_id"; $result = pg_query($conn, $sql); $listings = pg_fetch_all($result); for($index; $index < pg_num_rows($result); $index++) { $sql = "SELECT * FROM listings WHERE listing_id = '".$listings[$index]['listing_id']."'"; $listing_result = pg_query($conn, $sql); $arrayRow = pg_fetch_assoc($listing_result); echo (build_listing_card($arrayRow)); if($index !=0 && ($index +1) % IMAGE_LIMIT ==0){ break; } } ?> </div> <br/> <?php $total_pages = ceil(count($listings) / IMAGE_LIMIT); $pageLink = "<div class='pagination'>"; for ($i=1; $i<=$total_pages; $i++) { if($i == $page) { $pageLink .= "<a class='active' href='dashboard.php?page=".$i."'>".$i."</a>"; } else { $pageLink .= "<a href='dashboard.php?page=".$i."'>".$i."</a>"; } }; ?> </div> <br/> and this is the code for the listing-display page where I want all the listing information to be displayed <?php if (isset($_GET['listing_id'])) { $_SESSION['listing_id'] = $_GET['listing_id']; } else { $_SESSION['listing_id'] = 0; echo "ERROR: listing information was not find"; } $sql = 'SELECT * FROM listings WHERE listing_id = ' . $_SESSION['listing_id']; echo "<BR>".$sql; $result = pg_query(db_connect(), $sql); $records = pg_num_rows($result); echo "<BR>".pg_fetch_result($result, 0, "listing_id"); echo "<BR>".pg_fetch_result($result, 0, "user_id"); echo "<BR>".pg_fetch_result($result, 0, "status"); echo "<BR>".pg_fetch_result($result, 0, "price"); echo "<BR>".pg_fetch_result($result, 0, "headline"); echo "<BR>".pg_fetch_result($result, 0, "description"); echo "<BR>".pg_fetch_result($result, 0, "postal_code"); echo "<BR>".pg_fetch_result($result, 0, "images"); echo "<BR>".pg_fetch_result($result, 0, "city"); echo "<BR>".pg_fetch_result($result, 0, "property_options"); echo "<BR>".pg_fetch_result($result, 0, "bedrooms"); echo "<BR>".pg_fetch_result($result, 0, "bathrooms"); echo "<BR>".pg_fetch_result($result, 0, "garage"); echo "<BR>".pg_fetch_result($result, 0, "purchase_type"); echo "<BR>".pg_fetch_result($result, 0, "property_type"); echo "<BR>".pg_fetch_result($result, 0, "finished_basement"); echo "<BR>".pg_fetch_result($result, 0, "open_house"); echo "<BR>".pg_fetch_result($result, 0, "schools"); ?> <h1> Listing Display </h1> <hr/> <table style="width:50%" border="1px solid black"> <tr> <th>Listing Image</th> <th>Listing Description</th> </tr> <tr> <th rowspan="2"> <img src="" alt="Oshawa House" width="300px" height="200px"/> </th> <td align="left" valign="top"> <h3><?php echo pg_fetch_result($result, 0, "headline") ?></h3> <ul> <li>Open house?: <?php echo get_property('open_house', pg_fetch_result($result, 0, "open_house"))?> </li> <li>Finished Basement?: <?php echo get_property('finished_basement', pg_fetch_result($result, 0, "finished_basement"))?></li> <li><?php echo get_property('purchase_type', pg_fetch_result($result, 0, "purchase_type"))?></li> <li>Garage Type: <?php echo get_property('garage_type', pg_fetch_result($result, 0, "garage"))?></li> <li>Near school?: <?php echo get_property('schools', pg_fetch_result($result, 0, "schools"))?></li> <li>Status: <?php echo get_property('listing_status', strtolower(pg_fetch_result($result, 0, "status"))) ?></li> <li>Washrooms: <?php echo get_property('washrooms',pg_fetch_result($result, 0, "bathrooms")) ?></li> <li>Bedrooms: <?php echo get_property('bedrooms',pg_fetch_result($result, 0, "bedrooms")) ?></li> <li>Description: <?php echo pg_fetch_result($result, 0, "description") ?></li> </ul> </td> </tr> <tr> <td align="left" valign="top"><ul> <li>Location: <?php echo get_property('cities',pg_fetch_result($result, 0, "city")) ?></li> <li>Postal Code: <?php echo pg_fetch_result($result, 0, "postal_code") ?></li> <li>Price: <?php echo pg_fetch_result($result, 0, "price") ?></li> </ul> </td> </tr> </table> <form action="listing-matches.php"> <p> <input type="submit" name="submit" value="Back"/></p> </form>
-
Hi, I have a MySql query which currently looks like this Query = "select Question,Answer1,Answer2,Answer3,CorrectAnswer,id,Duplicate from Questions where id='" + RandomN.Text + "'" As you can see I have a table called 'Questions' which has several columns, Im using VB.NET I also have a textBox on a windows form called 'RandomN' What this does is it takes whatever number is in my textBox called RandomN.Text and looks for that number in the id column and returns all data on that row. What I am trying to acheive now is this, I have a column called Duplicate it will either contain the word 'True' or 'False' I would like it to only return data from the given number in the textBox if the Duplicate column in that row contains the word 'False' If someone can shed some light I would be greatful. Thanks
-
Hi . I have a very old and large site (mostly written with the help of phpfreaks !). I am now told by google that the site will display an "insecure get me out of here" type message if I do not secure the personal info (more than fair) I do not want to secure the whole site as I will lose 10 years of seo because, as I believe, google sees the secure site as a completely different site to the http site... not to mention the duplicate content issues have used this code that seem to work fine BUT when I leave the secure page the https stays for the whole site. # rewrite individual pages to https RewriteEngine on RewriteCond %{HTTPS} off RewriteRule ^login\.php$ https://www.test.com.au/login.php [L,R=301] RewriteEngine on RewriteCond %{HTTPS} off RewriteRule ^checkout\.php$ https://www.test.com.au/checkout.php [L,R=301] Any help is greatly appreciated Cheers and thanks
-
Hello I've been trying to fix this problem for around 3 weeks; so what I want is to be able to send a picture and being able to display it in another page. It send it to the server, but still it doesn't show it. Here is my code: <?php require_once('../Connections/connection.php'); ?> <?php $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "add_post")) { $tiempocotejo= time(); $insertSQL = sprintf("INSERT INTO posts (titulo, categoria, tag, imagen, contenido, descripcion, estatus, plantilla,link, price, autor) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['titulo'], "text"), GetSQLValueString($_POST['categoria'], "text"), GetSQLValueString($_POST['tag'], "text"), GetSQLValueString($_POST['imagen'], "text"), GetSQLValueString($_POST['contenido'], "text"), GetSQLValueString($_POST['descripcion'], "text"), GetSQLValueString($_POST['estatus'], "int"), GetSQLValueString($_POST['plantilla'], "int"), GetSQLValueString($_POST['link'], "text"), GetSQLValueString($_POST['price'], "text"), GetSQLValueString($_SESSION['MM_Id'], "int")); mysql_select_db($database_connection, $connection); $Result1 = mysql_query($insertSQL, $connection) or die(mysql_error()); mysql_select_db($database_connection, $connection); $query_SacarIdPost = sprintf("SELECT posts.id FROM posts WHERE time=%s",$tiempocotejo,"int"); $SacarIdPost = mysql_query($query_SacarIdPost, $connection) or die(mysql_error()); $row_SacarIdPost = mysql_fetch_assoc($SacarIdPost); $totalRows_SacarIdPost = mysql_num_rows($SacarIdPost); mysql_free_result($SacarIdPost); $updateSQL = sprintf("UPDATE posts SET urlamigable= %s WHERE id=%s", GetSQLValueString(limpia_espacios($_POST['titulo'],$row_SacarIdPost['id']), "text"), GetSQLValueString($row_SacarIdPost['id'], "int")); mysql_select_db($database_connection, $connection); $Result1 = mysql_query($updateSQL, $connection) or die(mysql_error()); $insertGoTo = "publishedpost" . UrlAmigablesInvertida($row_SacarIdPost['id']).".php"; header(sprintf("Location: %s", $insertGoTo)); } ?> <style> #select{ padding-left:0px; } #select2{ padding-right:0px; } </style> <!DOCTYPE html> <html lang="en"> <?php include("includes/head.php"); ?> <!-- Preloader --> <div id="preloader"> <div id="status"> </div> </div> <body> <div id="sb-site"> <!-- header-full --> <div class="boxed"> <?php include ("../includes/header.php");?> <?php include("../includes/menu.php");?> </div> <!-- header-full --> <header class="main-header" style="background-color:#f1f1f1;"></header> <!-- container --> <div class="container"> <div class="row"> <!-- Sidebard menu --> <?php include ("../includes/adminsidebar.php"); ?> <!-- Sidebar menu --> <!--Container --> <div class="col-md-9"> <form role="form" action="<?php echo $editFormAction; ?>" name="add_post" method="POST"> <!-- Title --> <div class="form-group"> <label>Title</label> <input type="text" class="form-control" name="titulo" placeholder="Enter title"> </div> <!-- Title --> <!-- upload image --> <div class="form-group"> <input class='file' type="file" class="form-control" name="imagen" onClick="gestionimagen.php" id="images" placeholder="Please choose your image"> </div> <!-- Upload Image --> <div class="form-group"> <label> Description </label><br> <textarea class="" name="descripcion" style="width:100%"></textarea> </div> <!-- Text editors --> <div class="form-group"> <label> Contenido </label> <textarea class="ckeditor" name="contenido"></textarea> </div> <!-- Text editor --> <!-- Category --> <div class="form-group"> <label>Categoria</label> <input type="text" class="form-control" name="categoria" placeholder="Enter categoria"> </div> <div class="form-group"> <label>Tag</label> <input type="text" class="form-control" name="tag" placeholder="Enter tag"> </div> <!-- Category --> <!-- Visibilidad --> <div class="col-md-6" id="select"> <div class="form-group"> <label for="select">Visible</label> <select class="form-control" id="estatus" name="estatus"> <option value="1">Si</option> <option value="0">No</option> </select> </div> </div> <!-- Visibilidad --> <!-- Tiplo de Plantilla necesito trabajar en esto!!!!! pero ya!!!--> <script> function plantilla(){ var formData = new FormData($("#formUpload")[0]); $.ajax({ type: 'POST', url: 'plantillapost.php', data: formData, contentType: false, processData: false }); } </script> <div class="col-md-6" id="select2"> <div class="form-group"> <label for="select">Plantilla</label> <select class="form-control" id="plantilla" name="plantilla"> <option value="1" <?php if (!(strcmp(1, ""))) {echo "SELECTED";} ?>>Normal</option> <option value="2" onClick="plantilla" <?php if (!(strcmp(2, ""))) {echo "SELECTED";} ?>>Full-Width</option> </select> </div> </div> <!-- Tipo de Plantilla --> <div class="col-md-6" id="select"> <div class="form-group"> <label>Link</label> <input type="text" class="form-control" name="link" placeholder="Enter link"> </div> </div> <div class="col-md-6" id="select2"> <div class="form-group"> <label>Price</label> <input type="text" class="form-control" name="price" placeholder="Enter price"> </div> </div> <button type="submit" class="btn btn-ar btn-primary pull-right">Agregar</button> <input type="hidden" name="MM_insert" value="add_post"> </form> </div> <!-- Container --> </div> </div> <!-- container --> <?php include("../includes/footer.php");?> </div> <!-- boxed --> </div> <!-- sb-site --> <?php include("../includes/menuderecha.php");?> <!-- sb-slidebar sb-right --> <?php include("../includes/back-to-top.php");?> <!-- Scripts --> <!-- Compiled in vendors.js --> <!-- <script src="js/jquery.min.js"></script> <script src="js/jquery.cookie.js"></script> <script src="js/imagesloaded.pkgd.min.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/bootstrap-switch.min.js"></script> <script src="js/wow.min.js"></script> <script src="js/slidebars.min.js"></script> <script src="js/jquery.bxslider.min.js"></script> <script src="js/holder.js"></script> <script src="js/buttons.js"></script> <script src="js/jquery.mixitup.min.js"></script> <script src="js/circles.min.js"></script> <script src="js/masonry.pkgd.min.js"></script> <script src="js/jquery.matchHeight-min.js"></script> --> <script src="<?php echo $urlWeb ?>js/vendors.js"></script> <!--<script type="text/javascript" src="js/jquery.themepunch.tools.min.js?rev=5.0"></script> <script type="text/javascript" src="js/jquery.themepunch.revolution.min.js?rev=5.0"></script>--> <!-- Syntaxhighlighter --> <script src="<?php echo $urlWeb ?>js/syntaxhighlighter/shCore.js"></script> <script src="<?php echo $urlWeb ?>js/syntaxhighlighter/shBrushXml.js"></script> <script src="<?php echo $urlWeb ?>js/syntaxhighlighter/shBrushJScript.js"></script> <script src="<?php echo $urlWeb ?>js/DropdownHover.js"></script> <script src="<?php echo $urlWeb ?>js/app.js"></script> <script src="<?php echo $urlWeb ?>js/holder.js"></script> <script src="<?php echo $urlWeb ?>js/home_profile.js"></script> <script src="<?php echo $urlWeb ?>js/efectos.js"></script> </body> </html> But Im still not able to display it, si I tried to do a tutorial that I saw on Internet and it made do another php file, that why I put on the input an action="gestionimagen.php" otherwise I would have never done, here is my code for gestionimagen.php: NOTE: I had to create another table on my server called images, but I would like to be able to do it in my table called posts as I have in the code above. <?php require_once '../Connections/connection.php'; $data = array(); if( isset( $_POST['image_upload'] ) && !empty( $_FILES['imagen'] )){ $image = $_FILES['imagen']; $allowedExts = array("gif", "jpeg", "jpg", "png"); if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } //create directory if not exists if (!file_exists('imagen')) { mkdir('imagen', 0777, true); } $image_name = $image['name']; //get image extension $ext = strtolower(pathinfo($image_name, PATHINFO_EXTENSION)); //assign unique name to image $name = time().'.'.$ext; //$name = $image_name; //image size calcuation in KB $image_size = $image["size"] / 1024; $image_flag = true; //max image size $max_size = 512; if( in_array($ext, $allowedExts) && $image_size < $max_size ){ $image_flag = true; } else { $image_flag = false; $data['error'] = 'Maybe '.$image_name. ' exceeds max '.$max_size.' KB size or incorrect file extension'; } if( $image["error"] > 0 ){ $image_flag = false; $data['error'] = ''; $data['error'].= '<br/> '.$image_name.' Image contains error - Error Code : '.$image["error"]; } if($image_flag){ move_uploaded_file($image["tmp_name"], "../images/post".$name); $src = "../images/post".$name; $dist = "../images/post/thumbnail_".$name; $data['success'] = $thumbnail = 'thumbnail_'.$name; thumbnail($src, $dist, 200); $sql="INSERT INTO images (`id`, `original_image`, `thumbnail_image`, `ip_address`) VALUES (NULL, '$name', '$thumbnail', '$ip');"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } } mysqli_close($con); echo json_encode($data); } else { $data[] = 'No Image Selected..'; } ?> So I don't know if did properly explain myself, but thats what I want, send the picture to my server into my table called posts, otherwise can you help me how to properly adapt it to the new table called "images" .
-
Hello PHP freak members I learn how to ecrypt my password using the blow fish method but I'm having trouble decypting the password. Is there anyone that can over see the problem that I'm having? Sample ecrypted password > $2y$09$Q5klufp7bj6iuBA3dHpz5.fLN1sLzeGKE7nuXKunLMKKvE.rZtSTW Original password > 1234 <?php error_reporting(E_ALL & ~E_NOTICE); session_start(); if(isset ($_SESSION['id'])){ header('location: profile.php'); } else { if($_POST['submit']){ include "connect_prompt/connect_query.php"; $email = mysqli_real_escape_string($db_conx,$_POST['email']); $password_one = $_POST['password_one']; ///////////////// Blow Fish /////////////////////////////////// function cryptPass($input, $rounds = 9){ $salt = ""; $saltChars = array_merge(range('A','Z'),range('a','z'),range(0,9)); for($i = 0; $i < 22; $i++){ $salt .= $saltChars[array_rand($saltChars)]; } return crypt($input, sprintf('$2y$%02d$', $rounds) . $salt); } $password_one = $_POST['password_one']; $password = $_POST['password']; $hashedPass = cryptPass($password); if(crypt($password_one, $hashedPass) == $hashedPass){ ///////////////// Blow Fish /////////////////////////////////// $sql = "SELECT id, email, password FROM customer WHERE email='$email' AND password='$password_one' LIMIT 1"; $query = mysqli_query ($db_conx, $sql); if($query){ $row = mysqli_fetch_row($query); $userID = $row[0]; $db_email = $row[1]; $db_password = $row[2]; } if($email == $db_email && $password_one == $db_password){ $_SESSION['email'] = $email; $_SESSION['id'] = $userID; header("location: profile.php"); } else { echo "Sorry, Username or Password was incorrect"; } } } } ?> <form action="login.php" method="POST"> <input type="email" name="email" id="email" placeholder=" your@email.com" /> <br/><br/> <input type="password" name="password_one" id="password_one" placeholder=" ********" /> <br/><br/> <input type="submit" name="submit" value="SIGN IN" /> </form>
-
this is tricky to explain: I have a raw php script, written by someone else, that sends an email to a list extracted from a CSV file. It requires that certain values in the file be manually edited each time it's used, such as the following: $mail->setFrom('email@email.com', 'From Name'); // <==== change email address, From Name $subject = "Subject Line"; // <==== Adjust this subject $html = ' html here '; // <==== include email html MagicParser_parse("test.csv","myRecordHandler","csv|44|1|34"); // <==== change 'test.csv' file name the function is called by simply calling this email.php file in the browser. I'd like to build a form that would a) edit these values/strings on the fly and then b) call the file in the browser. The thing is, it's been a while since I've messed with PHP forms to any extent, and I can't remember how to get started on something like this. And I'm not familiar at all with fopen and fwrite to edit strings like this without messing up the existing code (there's a lot of other code in the file that needs to be left alone, obviously). I'm hoping someone can help me with a starting point - an idea on how to get this thing going - whether to build the form right in the same file or to build one in another file that posts these values to this existing file... hopefully someone can understand what I'm asking, and thank you much for your help. regards, glenn
-
Hi Everyone, I am currently building a new website and the last big thing I need to finish is the PHP handling the forms we have built. Whenever I go to the page and submit the form, it seems to get into a never ending loop. I am not sure if the problem is in the code or if it is server side. Any assistance would be appreciated. I do not have much experience with PHP at all. I am going to attach the code below. The first file will contain the form and the second will be the PHP. Again, thank you for any suggestions you can provide. I am hoping the solution is simple. If I need to provide more information, let me know. form.html requestdemo.php
-
Hey guys! I have a page that has multiple forms. I am trying to make a button that will save all the information from each textarea to a different .txt file. IE: textarea1 will save to textarea1.txt textarea2 will save to textarea2.txt textarea3 will save to textarea3.txt etc. I am able to save each individual form via individual submit buttons within each form, but I'd like to make a submit button outside of the other forms that saves all forms to their specific files. The code for one of the individual forms looks like this: <form method="post" action="?"> <h1>Physical Stats</h1> <textarea name="stats"><?php include ('resources/stats.txt'); ?></textarea> <br><input type="submit" name="update_stats" value="Update"/> </form> <?php if (isset($_POST['update_stats'])) { file_put_contents("resources/stats.txt", $_POST['stats']); } ?> Everything above works. And the code for the save all form looks like this: <form method="post" action="?"> <input type="submit" name="update_all" value="Update All"/> <br><br> </form> <?php if (isset($_POST['update_all'])) { file_put_contents("resources/stats.txt", $_POST['stats']); file_put_contents("resources/pro_exp.txt", $_POST['pro_exp']); file_put_contents("resources/pro_awards.txt", $_POST['pro_awards']); file_put_contents("resources/ama_exp.txt", $_POST['ama_exp']); file_put_contents("resources/ama_awards.txt", $_POST['ama_awards']); file_put_contents("resources/references.txt", $_POST['references']); } ?> This is the code I currently have and it's just not working. Right now the above code is actually clearing all of the text files. I'm afraid I'm a complete newb to writing scripts and I'm sure there is some rule about file_get_contents that I'm not aware of. Please help! Thanks!
-
In the following pages I'm trying to validate if a user is signed in or not. If the user is signed in I would like to see 'Log Out' printed to the screen(I'll do more with that later). If the user is not signed in I would like to see a login form at the top right of the screen. As it stands I'm only seeing 'Log Out' on the screen, I can't get the form to show up anymore. I thought it might be because the session variable was still hanging around but I restarted my computer to make absolutely sure but I'm still just getting 'Log Out'. At the moment I need this program to work as is as much as possible. If you see an entirely different approach that you would use that's fine but I don't currently have the time to go changing a lot, I need to get this going kinda quick. Thanks. records-board.php <?php require_once('includes/init.php'); if(!isset($_SESSION)) { init_session(); } ?> <html> <head> <Title>Pop Report</title> <link rel="stylesheet" type="text/css" href="styles/popreport2.css"> <h1>Pop Report</h1> </head> <body> <?php if(isset($_POST['nameinput']) && isset($_POST['passinput'])) { $nameinput = $_POST['nameinput']; $passinput = $_POST['passinput']; User::sign_in($nameinput, $passinput); } if(!isset($_SESSION['user'])) { print_form(); } else { echo "Log Out "; echo $_SESSION['user']->name; // this line was just trouble shooting, it told me nothing! } ?> user.php <?php if(!isset($_SESSION)) { init_session(); } class User { public $name; public function __construct($username, $password) { $connection = get_db_connection(); $query = $connection->query("SELECT * FROM users WHERE username='$username' AND password='$password'"); if(!$query) { echo "Invalid username or password"; } else { $result = $query->fetch(PDO::FETCH_ASSOC); if(!$result['username'] == $username || !$result['password'] == $password) { echo "Invalid username or password"; } else { $this->name = $result['username']; } } } public static function sign_in($username, $password) { $_SESSION['user'] = new User($username, $password); } } ?> <?php function print_form() { echo "<form id='loginform' name='loginform' action='records-board.php' method='post'>"; echo "Username: <input type='text' name='nameinput'>"; echo "Password: <input type='text' name='passinput'><br />"; echo "<input type='submit' value='Sign In'>"; echo "</form>"; } ?>
-
If I have a php file that generates an html form from another php file which file would be the default file that would try to execute if I leave the action field blank in the html form? The php file that the form sits in or the php file that it's called from? Thanks.
-
I’m trying to post data to a MySQL DB table. In fact I’m working on learning how to interact with a DB from a web form. I had it almost working a couple of times but when I start trying to tweak it, it all goes awry. But the consistent issue that keeps popping up is an issue with “ Incorrect integer value: ':age' for column 'age' at row 1 “ This table "people" in the DB "peoples" has 3 columns; “id”, “name”, “age”. I was able to get it to work as long as I stuck with a numbered array. But when I try to use an associative array I start getting the error. The only thing I can think of is the id field in the DB. That maybe that’s throwing off my row count. Though obviously I don’t want to display the id field data in my webpage. So here’s the basic code I’m trying to make work. <?php include 'connForm.php'; ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>PDO with Forms</title> </head> <body> <form method="post" action="connform.php"> Name: <input type="text" id="name" name="name" /> <br /> Age: <input type="text" id="age" name="age" /> <br /> <input type="submit" value="add" /> <br /> </form> <br /> <br /> </body> </html> <?php echo htmlentities($row['name']). " is " . htmlentities($row['age']). " years old " . "<br>"; ?> conform.php contains the following code… <?php try { $db = new PDO('mysql:host=127.0.0.1;dbname=peoples', 'root', 'r00t'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { echo $e->getMessage(); echo '<br>'; echo 'You may have a problem'; } $stmt = $db->query('SELECT * FROM people'); $result = $stmt->fetchAll (); foreach($result as $row) { $name = htmlentities($row ['name']); $age = htmlentities($row ['age']); } if(isset($_POST ['name']) ) { $name = $_POST ['name']; $age = $_POST ['age']; $stmt = $db ->prepare ("INSERT INTO people (name, age) VALUES (':name', ':age') "); $stmt ->bindValue(':name', $_POST ['name']); $stmt ->bindValue(':age', $_POST ['age']); $stmt ->execute (); } ?> One of the biggest problems with trying to learn anything from the internet isthat everybody has their own way of doing everything and each one wants to show off their precieved expertise. This means that trying to learn anything means trying to distill all these dispirit methods into the simplest cut & dried method I can manage. oddly of all the tutorials out there on YouTube dealing with PHP and PDO there are almost none dealing with PDO and web forms. I say "none" I mean, like 2 maybe 3 though I don't think I've found #3.
-
Hi, I have a user edit page that I cannot seem to get working correctly. We recently set out to add the addition of a avatar to our page. So... We edited the code and everything is working great for everyone but me. When I press submit on the form it sends me to a internal server error page instead of preloading the current page I am on. Everything that should get updated still does the only problem is the page will not load properly afterwards. I am at a complete wall and dont know where else to look. I was able to find out that if I remove a specific block of code the the page will reload but the picture will not update. 1. Picture wont upload but page will reload. 2. Picture will upload as expected but page doesnt reload correctly. Complete page code. <?php error_reporting(0); require('includes/application_top.php'); require('includes/classes/crypto.php'); $crypto = new phpFreaksCrypto; include('includes/classes/class.formvalidation.php'); include('includes/classes/class.phpmailer.php'); if (isset($_POST['submit'])) { $my_form = new validator; $mail = new PHPMailer(); if($_POST['password'] !== ''){ if($my_form->checkEmail($_POST['email'])) { // check for good mail if ($my_form->validate_fields('firstname,lastname,email,password')) { // comma delimited list of the required form fields if ($_POST['password'] == $_POST['password2']) { $allowedExts = array("gif", "jpeg", "jpg", "png"); $extension = end(explode(".", $_FILES["img"]["name"])); if ((($_FILES["img"]["type"] == "image/gif") || ($_FILES["img"]["type"] == "image/jpeg") || ($_FILES["img"]["type"] == "image/jpg") || ($_FILES["img"]["type"] == "image/pjpeg") || ($_FILES["img"]["type"] == "image/x-png") || ($_FILES["img"]["type"] == "image/png")) && ($_FILES["img"]["size"] < 3145728) && in_array($extension, $allowedExts)) { if ($_FILES["img"]["error"] <= 0) { $files = glob("upload/$user->userID.*"); foreach ($files as $file) { unlink($file); } move_uploaded_file($_FILES["img"]["tmp_name"], "upload/" . $user->userID.'.'.$extension); } } $salt = substr($crypto->encrypt((uniqid(mt_rand(), true))), 0, 10); $secure_password = $crypto->encrypt($salt . $crypto->encrypt($_POST['password'])); $sql = "update " . $db_prefix . "users "; $sql .= "set password = '".$secure_password."', salt = '".$salt."', firstname = '".$_POST['firstname']."', lastname = '".$_POST['lastname']."', email = '".$_POST['email']."', template_name = '".$_POST['template_name']."' "; $sql .= "where userID = " . $user->userID . ";"; //die($sql); mysql_query($sql) or die(mysql_error()); //set confirmation message header('Location: index.php'); } else { $display = '<div class="responseError">Passwords do not match, please try again.</div><br/>'; } } else { $display = str_replace($_SESSION['email_field_name'], 'Email', $my_form->error); $display = '<div class="responseError">' . $display . '</div><br/>'; } } else { $display = '<div class="responseError">There seems to be a problem with your email address, please check.</div><br/>'; } } elseif ($_post['password'] == ''){ if($my_form->checkEmail($_POST['email'])) { // check for good mail $allowedExts = array("gif", "jpeg", "jpg", "png"); $extension = end(explode(".", $_FILES["img"]["name"])); if ((($_FILES["img"]["type"] == "image/gif") || ($_FILES["img"]["type"] == "image/jpeg") || ($_FILES["img"]["type"] == "image/jpg") || ($_FILES["img"]["type"] == "image/pjpeg") || ($_FILES["img"]["type"] == "image/x-png") || ($_FILES["img"]["type"] == "image/png")) && ($_FILES["img"]["size"] < 3145728) && in_array($extension, $allowedExts)) { if ($_FILES["img"]["error"] <= 0) { $files = glob("upload/$user->userID.*"); foreach ($files as $file) { unlink($file); } move_uploaded_file($_FILES["img"]["tmp_name"], "upload/" . $user->userID.'.'.$extension); } } if ($my_form->validate_fields('firstname,lastname,email, template_name')) { // comma delimited list of the required form fields if ($_POST['password'] == '') { $sql = "update " . $db_prefix . "users "; $sql .= "set firstname = '".$_POST['firstname']."', lastname = '".$_POST['lastname']."', email = '".$_POST['email']."', template_name = '".$_POST['template_name']."' "; $sql .= "where userID = " . $user->userID . ";"; //die($sql); mysql_query($sql) or die(mysql_error()); //set confirmation message header('Location: index.php'); } else { $display = '<div class="responseError">Passwords do not match, please try again.</div><br/>'; } } else { $display = str_replace($_SESSION['email_field_name'], 'Email', $my_form->error); $display = '<div class="responseError">' . $display . '</div><br/>'; } } else { $display = '<div class="responseError">There seems to be a problem with your email address, please check.</div><br/>'; } } else { $display = '<div class="responseError">You broke all the things</div><br/>'; } } include('includes/header.php'); $sql = "select * from " . $db_prefix . "users where userID = " . $user->userID; $query = mysql_query($sql); if (mysql_num_rows($query)) { $result = mysql_fetch_array($query); $firstname = $result['firstname']; $lastname = $result['lastname']; $email = $result['email']; $template_name = $result['template_name']; } if (!empty($_POST['firstname'])) $firstname = $_POST['firstname']; if (!empty($_POST['lastname'])) $lastname = $_POST['lastname']; if (!empty($_POST['email'])) $email = $_POST['email']; if (!empty($_POST['template_name'])) $template_name = $_POST['template_name']; ?> <h1>Edit User Account Details</h1> <?php if(isset($display)) echo $display; ?> <form action="user_edit.php" method="post" name="edituser" enctype="multipart/form-data"> <fieldset> <legend style="font-weight:bold;">Enter User Details:</legend> <table cellpadding="3" cellspacing="0" border="0"> <?php if ($isGuest) { ?> <tr><td>First Name:</td><td><input type="text" name="firstname" value="<?php echo $firstname; ?>" readonly></td></tr> <tr><td>Last Name:</td><td><input type="text" name="lastname" value="<?php echo $lastname; ?>" readonly></td></tr> <tr><td>Email:</td><td><input type="text" name="email" value="NULL" size="30" readonly></td></tr> <?php } else { ?> <tr><td>First Name:</td><td><input type="text" name="firstname" value="<?php echo $firstname; ?>"></td></tr> <tr><td>Last Name:</td><td><input type="text" name="lastname" value="<?php echo $lastname; ?>"></td></tr> <tr><td>Email:</td><td><input type="text" name="email" value="<?php echo $email; ?>" size="30"></td></tr> <?php } ?> <tr><td>Favorite Team:</td><td><?php $template =$result['template_name'];?> <select name="template_name" > <option name="template_name" value="<?php echo "$template_name"; ?>">Choose your team template</option> <option value="main">NFL</option> <option value="ARI">Cardinals</option> <option value="ATL">Falcons</option> <option value="BAL">Ravens</option> <option value="BUF">Bills</option> <option value="CAR">Panthers</option> <option value="CHI">Bears</option> <option value="CIN">Bengals</option> <option value="CLE">Browns</option> <option value="DAL">Cowboys</option> <option value="DEN">Broncos</option> <option value="DET">Lions</option> <option value="GB">Packers</option> <option value="HOU">Texans</option> <option value="IND">Colts</option> <option value="JAX">Jaguars</option> <option value="KC">Chiefs</option> <option value="MIA">Dolphins</option> <option value="MIN">Vikings</option> <option value="NE">Patriots</option> <option value="NO">Saints</option> <option value="NYG">Giants</option> <option value="NYJ">Jets</option> <option value="OAK">Raiders</option> <option value="PHI">Eagles</option> <option value="PIT">Steelers</option> <option value="SD">Chargers</option> <option value="SEA">Seahawks</option> <option value="SF">49ers</option> <option value="STL">Rams</option> <option value="TB">Buccaneers</option> <option value="TEN">Titans</option> <option value="WAS">Redskins</option> </select></td></tr> <tr><td> </td></tr> <?php if ($isGuest) { ?> <?php } else { ?> <tr><td>New Password:</td><td><input type="password" name="password"></td></tr> <tr><td>Confirm Password:</td><td><input type="password" name="password2"></td></tr> <?php } ?> <tr><td> </td></tr> <tr><td>Avatar:</td><td><input type="file" name="img" id="img" <?php if ($isGuest) { ?> disabled <?php } ?>></td></tr> <tr><td> </td><td> <?php $avatars = glob("upload/$user->userID.*"); if(!empty($avatars)) { $avatar = $avatars[0]; echo '<img style="width:20%;" src="'.$avatar.'">'; echo '<p>**Note Image must be smaller than 3MB.</p>'; echo '<input type="submit" name="submit" value="Submit"></td></tr>'; echo '</table></fieldset></form></table></fieldset>'; include('includes/footer.php'); } else { $avatar = 'upload/default.jpg'; echo '<img style="width:20%;" src="'.$avatar.'">'; echo '<p>No avatar set, please upload one.<br>Image must be smaller than 3MB.</p>'; echo '<input type="submit" name="submit" value="Submit"></td></tr>'; echo '</table></fieldset></form></table></fieldset>'; include('includes/footer.php'); } require 'includes/correctImageOrientation.php'; correctImageOrientation('upload/'); ?> If I remove this specific piece of code then I have the case where the page loads fine but picture wont upload. $allowedExts = array("gif", "jpeg", "jpg", "png"); $extension = end(explode(".", $_FILES["img"]["name"])); if ((($_FILES["img"]["type"] == "image/gif") || ($_FILES["img"]["type"] == "image/jpeg") || ($_FILES["img"]["type"] == "image/jpg") || ($_FILES["img"]["type"] == "image/pjpeg") || ($_FILES["img"]["type"] == "image/x-png") || ($_FILES["img"]["type"] == "image/png")) && ($_FILES["img"]["size"] < 3145728) && in_array($extension, $allowedExts)) { if ($_FILES["img"]["error"] <= 0) { $files = glob("upload/$user->userID.*"); foreach ($files as $file) { unlink($file); } move_uploaded_file($_FILES["img"]["tmp_name"], "upload/" . $user->userID.'.'.$extension); } } I attached the include file that I am using in case that is helpful as well. I am using php5.4 fastCGI on a godaddy server(plesk windows hosting) correctImageOrientation.php
- 1 reply
-
- forms
- upload image
-
(and 2 more)
Tagged with:
-
I apologize in advance if this has already been covered before, but I'm extremely new to php and a lot of this is over my head... That being said, I've created a form, and I can't for the life of me get it to send like it's supposed to. I've scoured ever forum and tutorial I can think of, and have tried every possible code combination I can think of, but nothing seems to be help. Whenever I hit send on the website, I get a redirect that just says "Forbidden". Nothing else. I'm not sure what information I should provide for forum members to be able to help me, but the website/page I'm having issues with is: http://www.joessportscafe.com/feedback . If you go into the source code, the php starts on line 239 and ends on 519. I can provide whatever more information you need if anyone would be awesome enough to help me. I would REALLY appreciate it.
-
Hi everyone, i am marking a number of php questionnaire forms on my webpage and they connect up to a Mysql database, so far so good. However, the part i am having trouble with is... i need certain questionnaires to only be released for fixed periods of time (for example 1/2 weeks). Would anyone be able to help me out and give me some idea of how i would go about this? Thanks
- 3 replies
-
- questionnaire
- php
-
(and 2 more)
Tagged with:
-
<h2>Scholarship Form</h2> <form name="scholarship" action="process_Scholarship.php" method="post"> <p>First Name: <input type="text" name="fname" /></p> <p>Last Name: <input type="text" name="lname" /></p> <p><input type="reset" value="Clear Form" /> <input type="submit" value="Send Form" /></p> </form> <?php error_reporting(E_ALL); ini_set('display_errors', 'on'); $firstName = validateInput($_POST['fname'], "First Name"); $lastName = validateInput($_POST['lname'], "Last Name"); if ($errorCount<0) echo "Please use the \"Back\" button to re-enter data.<br />\n"; else echo "<p>Thank you for filling out the scholarship form, ".$firstName." ".$lastName."."; function displayRequired($fieldName) { echo "The field \"$fieldName\" is required.<br />\n"; } function validateInput($data, $fieldName) { global $errorCount; if (empty($date)) { displayRequired($fieldName); ++$errorCount; $retval = ""; } else {//Only clean up the input if it isn't empty $retval = trim($data); $retval = stripslashes($retval); } return($retval); } $errorCount = 0; ?> it always reads the form as empty, and spits out the error message. why will it not read the names I enter?
-
Hi I am trying to build a contact form and my form isnt sending. Here is my code. (its in a modal window)(I have my email address in the $to variable in the code) <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = 'From: Jarrod'; $to = 'email'; $subject = "Landing page"; $body = "From: $name\n Email: $email\n Message:\n $message"; ?> <?php if ($_POST['submit']){ if(mail ($to, $subject, $body, $from)) { echo '<p>Your message has been sent!</p>'; }else{ echo '<p>Something went wrong, go back!</p>'; } } ?> <div class="modal fade" id="contact" role="dialog"> <div class=" modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h2>Contact us</h2> </div> <div class="modal-body"> <form method="post" action="index1.php"> <div class="form-horizontal"> <label for="Name">Your Name</label> <input type="text" class="form-control" id="name" placeholder="Name"> <label for="Email">Your Email</label> <input type="Email" class="form-control" id="email" placeholder="Email"> <label for="Message">Message</label> <textarea class="form-control" id="message" placeholder="Message"></textarea> <input type="submit" value="Send">Send</button> </form> <div class="modal-footer"> <a class="btn btn-default" data-dismiss = "modal">Close</a> </div> </div> </div> </div>
-
Hi I am currently using bootstrap to design a landing page. I want to add a contact us form and I need to use a text area for long messages. When I use it with bootstrap it just appears as a single line and not a large field. How can I style just 1 field instead of all of them? This is my HTML code. <form> <div class="form-horizontal"> <label for="Name">Your Name</label> <input type="text" class="form-control" id="Name" placeholder="Name"> <label for="Email">Your Email</label> <input type="Email" class="form-control" id="Email" placeholder="Email"> <label for="Message">Message</label> <input type="textarea" class="form-control" id="Message" placeholder="Message"> </form>
-
I am trying to create a page for customers to enter their details. I am using a html form. When the submit button is pressed the form posts the inputs to the same page, which then checks if the inputs are empty. If they are not then each post variable is allocated a session variable so this info can be accessed late on in the system. If some of the inputs are empty then the value of the input forms become equal to the session variables that they were just allocated to so that the customer doesn’t have to retype their information. This is where the problem occurs. When I load the page each input box has a slash inside it and when the submit button is pressed a mother slash is added. My code is below: <?php session_start(); if(isset($_POST['NextPage'])){ if (!empty($_POST['CName'])){ $_SESSION["CName"] = $_POST['CName']; if (!empty($_POST['CStreet'])){ $_SESSION["CStreet"] = $_POST['CStreet']; if (!empty($_POST['CTown'])){ $_SESSION["CTown"] = $_POST['CTown']; if ($_POST['Counties'] != "-"){ $_SESSION["CCounty"] = $_POST['Counties']; if (!empty($_POST['CPostcode'])){ $_SESSION["CPostcode"] = $_POST['CPostcode']; if (!empty($_POST['CEmail'])){ $_SESSION["CEmail"] = $_POST['CEmail']; if (!empty($_POST['CNumb'])){ $_SESSION["CNumb"] = $_POST['CNumb']; $NotEmpty = true; }else{ $ErrorMsg = "Number is empty. </br>"; } }else{ $ErrorMsg = "Email is empty. </br>"; } }else{ $ErrorMsg = "Postcode is empty. </br>"; } }else{ $ErrorMsg = "County is empty. </br>"; } }else{ $ErrorMsg = "Town is empty. </br>"; } }else{ $ErrorMsg = "Street is empty. </br>"; } }else{ $ErrorMsg = "Name is empty. </br>"; } } $content = ' <h3 id="CTitle"> Customer Details </h3> <p><i>'.$ErrorMsg.'</i></p> <form action=" " method="POST" name="CDetails" id="CDetails"> Name: * <input type="text" name="CName" size="30" value='.$_SESSION["CName"].'/></br> First line of your address: * <input type="text" name="CStreet" size="40" value='.$_SESSION["CStreet”];.’/></br> Town: * <input type="text" name="CTown" size="25" value='.$_SESSION["CTown"].'/></br> Postcode: * <input type="text" name="CPostcode" size="11" value=‘.$_SESSION["CPostcode"].'/></br> Email address: * <input type="text" name="CEmail" size ="35" value='.$_SESSION["CEmail”];.’/></br> Phone Number: * <input type="text" name="CNumb" value='.$_SESSION["CNumb"].'/></br> <input type="submit" name="NextPage" value="Next" id="Next”/> </form> ?>
-
I'd describe myself as a "basic" php programmer.... I'm trying to build my first multi-page forms. The first page is calculator_q1.php No session variables are needed here, I have omitted a few options, the code looks like this <form id="page1" method="post" action="calculator_q2.php"> <h1>1. Which best describes the primary and secondary sports combination that will be played on your pitch?</h1> <table> <tr><td>Rugby only</td><td><input type="radio" name="1_primary_secondary_combo" value="Rugby only"></td></tr> <tr><td>Rugby/Soccer</td><td><input type="radio" name="1_primary_secondary_combo" value="Rugby Soccer"></td></tr> <tr><td>Soccer/Hockey</td><td><input type="radio" name="1_primary_secondary_combo" value="Soccer Hockey"></td></tr> </table> <input class="blue" type="submit" value="Next"> </form> The 2nd page is calculator_q2.php. This has some php to start the session, copy the result of form 1 to a session var, I do a debug echo and the variable is printed correctly so I think have captured it correctly. In extract, I do this: <?php //Start the session session_start(); //Store our posted values in the session variables $_SESSION['1_primary_secondary_combo'] = $_POST['1_primary_secondary_combo']; ?> <?php $debug=True; if ($debug) { echo ("Debug: session for q1 = ".$_SESSION['1_primary_secondary_combo']); } ?> <form id="page2" method="post" action="calculator_q3.php"> <h1>2. Please choose a preferred surface</h1> <table> <tr><td>3G Rubber Crumb Filled Turf</td><td><input type="radio" name="2_preferred_surface" value="3G Rubber Crumb Filled Turf "></td></tr> <tr><td>Sand Filled Turf</td><td><input type="radio" name="2_preferred_surface" value="Sand Filled Turf"></td></tr> <tr><td>Sand Dressed Turf or<br>a Water Based Surface</td><td><input type="radio" name="2_preferred_surface" value="Sand Dressed Turf or a Water Based Surface"></td></tr> </table> <p> <script> function submitForm(action){ document.getElementById('page2').action = action; document.getElementById('page2').submit(); } </script> <input class="blue" type="button" onclick="submitForm('/calculator_q1.php')" value="Previous" /> <input class="blue" type="button" onclick="submitForm('/calculator_q3.php')" value="Next" /> </form> So far so good, but when I introduce page 3 (calculator_q3.php) then it prints the previous page's (from page 2) variable but can't find the session variable from question 1. This is from calculator_q3.php: <?php //Start the session session_start(); //Store our posted values in the session variables $_SESSION['2_preferred_surface'] = $_POST['2_preferred_surface']; ?> <?php $debug=True; if ($debug) { echo ("Debug: session for q1 = ".$_SESSION['1_primary_secondary_combo']); echo ("<br>Debug: session for q2 = ".$_SESSION['2_preferred_surface']); } ?> <form id="page3" method="post" action="calculator_q4.php"> <h1>3. Please choose one watering option</h1> <table> <tr><td>With a Rain Gun System</td><td><input type="radio" name="3_watering_option" value="With a Rain Gun System"></td></tr> <tr><td>With a Rain gun System + Water Borehole</td><td><input type="radio" name="3_watering_option" value="With a Rain gun System + Water Borehole"></td></tr> <tr><td>Not Required</td><td><input type="radio" name="3_watering_option" value="Not Required"></td></tr> </table> <p> <script> function submitForm(action){ document.getElementById('page3').action = action; document.getElementById('page3').submit(); } </script> <input class="blue" type="button" onclick="submitForm('/calculator_q2.php')" value="Previous" /> <input class="blue" type="button" onclick="submitForm('/calculator_q4.php')" value="Next" /> </form> To see this in action see: http://www.sports.hardingweb.net/calculator_q1.php Any insights would be appreciated. Many thanks.
-
As a complete newbie to php and webdesigning i have a following problem.I would like to retrieve the data from database and display it in a drop down menu.Then i should allow the user to select the values from drop down list along with other details,in other words i have to embed the drop down output as the form input for the user and store the form data in another table.I am running a xampp server and i am using php 5.4 version.Please help.My code is as follows.In this case project_name is displayed as the drop down output.but how do i use the same drop down output as a input in the form. <html> <head></head> <body> <?php error_reporting(E_ALL ^ E_DEPRECATED); include 'connect.php' ; $tbl_name="projects"; $sql="SELECT project_name FROM $tbl_name "; $result=mysql_query($sql); if($result === FALSE) { die(mysql_error()); } ?> <form name="resources" action="hourssubmit.php" method="post" > <?php echo "<select name='project_name'>"; while ($row = mysql_fetch_array($result)) { echo "<option value='" . $row['project_name'] ."'>" . $row['project_name'] ."</option>"; } echo "</select>"; ?> </form> </body> </html>
-
Hi guys, Sorry im a bit of a noob when it comes to PHP but I just wondered if someone had an idea on how I could solve this PHP problem. I have a PDO statement that gets all users from a database. With the array of users from the database I create a foreach loop to display all of the users in a table which I want to use to select a specific user, enter a number in the row next to the user I select, then click submit and store the users name and also the number in vairables. I will use this information to populate another database later. My question is, I cant seem to reference the user or the number in the table to extract the user and number I enter. When I try and request the numbered entered in the index.php, it will only ever display a number if I enter a number for a the final user in the table. When I try and view the FullName it never works and I get 'Undefined index: FullName' error. I also specified to 'POST in the form but it doesnt seem to be doing that. Does anyone have any ideas? Thanks //function.php function getRequestors($tableName, $conn) { try { $result = $conn->query("SELECT * FROM $tableName"); return ( $result->rowCount() > 0) ? $result : false; } catch(Exception $e) { return false; } } //form.php <form action "index.php" method "POST" name='form1'> <table border="1" style="width:600px"> <tr> <th>Name</th> <th>Number Entered</th> <tr/> <tr> <?php foreach($users as $user) : ?> <td width="30%" name="FullName"><?php echo $user['FullName']; ?></td> <td width="30%"><input type="int" name="NumberedEntered"></td> <td><input type="submit" value="submit"></td> </tr> <?php endforeach; ?> </table> </form> //index.php if ( $_REQUEST['NumberedEntered']) { echo $_REQUEST['NumberedEntered']; echo $_REQUEST['FullName']; }
-
Hi, I am a curious fellow just beginning to use PHP. I understand the basics of what the $_GET and $_POST superglobals do, and how we can use them to retrieve data after form submission. I also know that since $_GET and $_POST are just associate arrays, we can create our own values in both $_GET and $_POST by writing statements like $_POST['variable'] = "value". I am wondering if it is at all possible to send data beyond form data by adding new key/value pairs into $_GET and $_POST. So for example, if I had a form that transferred username/password through Post, would it be possible for me to include further data by just saying $_POST['formtype'] = "house_insurance_form"? Basically what I'm getting at is trying to physically add your own data to $_POST or $_GET that you could pull from the next page where the form redirects to. In other words, can I send data beyond form data using these superglobals? I know I can do this with $_SESSION, but could I do it through $_POST or $_GET? I haven't been able to accomplish this, and I was just wondering if someone could give me an in-depth explanation of how this might work or how this is not possible. I would really really really appreciate it. Best Regards, -Sky
-
Hey guys! I am trying to create a script to "promote" all my members at once based on some forum measurements. Here is my code (pastebin). I don't know what is wrong. The page is blank and won't even load. Please help. http://pastebin.com/aZeKq1Zw Note: This is within the vBulletin 4.2.2 framework.