-
Posts
2,134 -
Joined
-
Last visited
-
Days Won
42
Everything posted by benanamen
-
Your complicating a simple matter. Get rid of those nested tables! <?php error_reporting(-1); ini_set('display_errors', 1); if ($_POST) { $error['fname'] = empty($_POST['fname']) ? "<span class='error'>Please enter your last name.</span>" : ''; $error['lname'] = empty($_POST['lname']) ? "<span class='error'>Please enter your last name.</span>" : ''; } ?> <!doctype html> <html> <head> <meta charset="utf-8"> <style type="text/css"> </style> <title>Untitled Document</title> </head> <body> <table id="contactForm" border cellspacing="20"> <form method="post"> <tr> <td class="question" >First Name:<br /> <input type="text" name="fname" size="15" value ="<?php echo !empty($_POST['fname']) ? $_POST['fname'] : '';?>" > <?php echo !empty($error['fname']) ? $error['fname'] : '';?> </td> <td class="question">Last Name<br /> <input type="text" name="lname" size="20"><?php echo !empty($error['lname']) ? $error['lname'] : '';?> </td> <td class="question">Organization's Name:<br /> <input type="text" name="orgName" size="15" maxlength="50"> </td> </tr> <tr> <td class="question">Street Address: <br /> <input type="text" name="address" size="15" maxlength="50"> </td> <td class="question">City: <br /> <input type="text" name="city" size="10" maxlength="25"> </td> <td class="question"> State: <br /> <select name = "state" value=""> <option value ="Please choose a state"> Please choose a state </option> <?php //states($state); ?> </select> </td> <td class="question">Zipcode:<br /> <input type="number" name="zipcode" size="5" maxlength="5"> </td> </tr> <tr> <td>Phone Number: <br />(including area code) <br /> <input type="text" name="phone" size="10" maxlength="10"> </td> <td>Fax Number: <br />(including area code) <br /> <input type="text" name="fax" size="10" maxlength="10"> </td> </tr> <tr> <td>Email:<br /> <input type="text" name="email" /> </td> <td>Confirm Email:<br /> <input type="text" name="ConfirmEmail" /> </td> </tr> <tr> <td>What would you like help with? </td> <td> <table id="projectOptions"> <tr span=2> <td><input type="checkbox" name="SocialMedia">Social Media </td> <td><input type="checkbox" name="WebContentManagement">Web Content Management </td> </tr> <tr> <td><input type="checkbox" name="MarketingMaterials">Marketing Material Creation </td> <td><input type="checkbox" name="SEO">SEO (Search Engine Optimization) </td> </tr> <tr> <td><input type="checkbox" name="VideoEditing"> Video Editing </td> <td><input type="checkbox" name="WebDesign">Web Design </td> </tr> </table> </td> <tr> <td>Overview about the project: </td> <td><textarea></textarea></td> </tr> <tr> <td>If you are not a robot, what year is it? </td> <td><input type="text" name="year" size="4" maxlength="4"> </tr> <tr> <td><input type="submit" name="submit" value="Contact Me!"> </td> <td><input type="reset"></td> </tr> </form> </table> </body> </html>
-
Your problem is that submit is missing the name attribute Your code: <input type="submit" name="submit" value="Contact Me!"> Correct: <input type="submit" name="submit" value="Contact Me!"> You still have other issues. I may rewrite it for you. You are also missing a couple closing tags and you dont use tables for page layout. Use CSS.
-
Normally it would go above the html, but in this case, it needs to be where it is for the page to validate. OP, just noticed a couple problems. You cannot use the same id name more than once in a page. You have done it twice. Also this should have an = sign <div id-"string">
-
Submiting form with text fields and checkbox's Need help
benanamen replied to ericjw316's topic in PHP Coding Help
OP, so your not confused, $checkbox1 = isset($_POST['checkbox1']) ? 1 : 0; does the same exact thing as What I showed you is a Ternary Operator. It would behoove you to know how to use it. There is no need to have a value for the form check box. $checkbox1 = isset($_POST['checkbox1']) ? 'this_is_my_check_box_insert_value_not_a_number' : 0; A string will require to be quoted, a number no quotes. -
This works.... <!DOCTYPE html> <html> <head> <title>Hello!</title> </head> <body> <?php if(isset($_GET['source_file'])){ $SourceFile = file_get_contents( stripslashes($_GET['source_file'])); highlight_string($SourceFile); } else{ echo "<p>No source file name entered</p>\n"; } ?> ___________________________________________________________ <div id-"string"> <a id="string">String Functions</a> <p>This script counts the number of times each letter appears in a string andcompares that count to the number of times</p> <a href="SimiliarNames.php">Test Similiar Names Script</a> //Source file <a href="ShowSourceCode.php?source_file=ShowSourceCode.php">[View the Source Code]</a> </div> <div id="char"> <a id="char">Character Functions</a> <p>This script finds the number of words embedded</p> <a href="EmbeddedWords.php">Test EmbeddedWords Script</a> //Source file <a href="ShowSourceCode.php?source_file=ShowSourceCode.php">[View the Source Code]</a> </div> </body> </html>
-
Who told you not to store the token (Hash) in the database? What are you going to compare the users token to?
-
Ok, you really need to stop using programming words to describe your situation. It is not helping at all. survey class - OOP Programming term instance of this survey class - OOP programming term the properties - OOP programming term survey instance - OOP programming term session - programming term All the above have specific meanings to a programmer. You are going to continue to have problems getting help if you keep doing that. If I wanted you to hand me a hammer but I told you to hand me a screwdriver, you wouldn't be reaching for the hammer. At this point I am going to leave it up to someone else to decipher your problem.
-
@Barand, The example I posted is not an answer to the op's specific needs. It is STRICTLY a basic example to show how to calculate a percentage in MySQL. It of course needs to be modified/written for the specific results the OP wants. My position is that when the database can do something, that is where it should be done, not in code. Let the database do the work and get the data the way you want it from the start. The whole purpose of the DB is to manage data.
-
Ok, thats exactly what we really needed to know. And your use of programming terms with specific meaning to us will absolutely throw us off. Ok, now just explain this more clearly: "they can create an instance of a survey" What exactly does that mean? When you say to a programmer about creating an "instance" it has a whole other meaning. * It is your job to explain to the client he cant use programming words to describe other things.
-
Submiting form with text fields and checkbox's Need help
benanamen replied to ericjw316's topic in PHP Coding Help
The way check boxes work, unlike other form elements, is if the checkbox is not checked, nothing whatsoever about it gets submitted. So, you would need to see if the check box name isset. If it isset, it will always be not empty. (The value actually = on) $sab-owner = isset($_POST['sab-owner']) ? 1 : 0; Now, there is another option where you set the default value in the database to zero. When you do your insert, if you didn't insert a 1 for that column, it will automatically be zero. If you go that route, I would make a comment in the code that says that is what is happening so anyone else reading the code, including yourself years later will know whats going on. -
You didnt quite grasp my question. I dont want to know how you are trying to solve something. I want to know WHAT you are solving, the BIG Picture. The answer to my question lies in your answer to : "users of the application are permitted only one 'session' at a time" Why? What is the purpose for the "session" "so when a user attempts to create a new session" HOW? How are they creating a new session? By logging in again???? By someone else logging in as that user? It kinda sounds like you are only wanting one person logged in with that user id at the same time.
-
How to save multiple checkbox value using only 1 save button
benanamen replied to samuel_lopez's topic in PHP Coding Help
This should help give you an idea. <?php if ($_POST) { $db = new PDO("mysql:host=localhost;dbname=phphelp_form_array", "user", "pass"); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $insertStmt = $db->prepare("INSERT INTO datatable (field1, field2) VALUES (?,?)"); for ($i = 0; $i < count($_POST['field1']); $i++) { $insertStmt->execute(array( $_POST['field1'][$i], $_POST['field2'][$i] )); } } ?> <form action="<?php echo $_SERVER['script_name']; ?>" method="post"> <b>field1 1</b><br> <label>field1 <input type="text" name="field1[]"></label> <br> <label>field2 <input type="text" name="field2[]"></label> <br> <b>field1 2</b><br> <label>field1 <input type="text" name="field1[]"></label> <br> <label>field2 <input type="text" name="field2[]"></label> <input name="" type="submit" value="Submit"> </form> -
Forget your code a minute. What is the actual overall problem you are trying to solve or task you want to accomplish? I suspect you are going about solving it the wrong way.
-
How to save multiple checkbox value using only 1 save button
benanamen replied to samuel_lopez's topic in PHP Coding Help
Is this homework? -
I think the op is asking how to do it in SQL. Here is an example of using Mysql to calculate a percentage. Better to have the database do the work when it can. mysql> SELECT name, -> SUM(miles) AS 'miles/driver', -> (SUM(miles)*100)/@total AS 'percent of total miles' -> FROM driver_log GROUP BY name; +-------+--------------+------------------------+ | name | miles/driver | percent of total miles | +-------+--------------+------------------------+ | Ben | 362 | 16.712834718375 | | Henry | 911 | 42.059095106187 | | Suzi | 893 | 41.228070175439 | +-------+--------------+------------------------+
-
@Jacques1 already told you want to use to generate the token. Re-read his post. DO NOT USE rand!
-
You would need to set a session counter.The example assumes you dont want them back to the first page at all after refresh. (SESSION will still be set and keep redirecting) <?php session_start(); if( isset( $_SESSION['counter'] ) ) { header('Location: http://www.example.com/'); } else { $_SESSION['counter'] = 1; } ?>
-
You don't use tables to format a form or page. You need to use CSS.
-
I can help you more exactly if you can provide an sql dump of your DB so I can run it locally.
-
FYI:
-
But, but, you said... Your WHERE condition is only going to get you a record(s) matching the SalesID and TempCode Did you really name your timestamp column timestamp? You know thats a MySQL Reserved Word dont you? Why did you do that? You were OK with a timestamp column for what you are doing. Its the same exact format as datetime. The query I gave you may not work on datetime, it uses the timestampdiff function.
-
You left out that detail my brutha. SELECT *, IF(timestampdiff(minute, timestamp_column, Now()) > 20, 'More than 20', 'Less Than 20') AS status FROM your_table
-
My "storage" answer may have not been correct. See the attached image. Doesn't this say the the database itself is UTF8 and therefore would not need it in the connection string? Edit* Just noticed it says character_set_server = latin