Form Processing: Change The "action=" Based On Pull Down Menu
I have an html form for that uses username and password to login to a specific area of the website. The "area" the user wants to go to is based on a pull down menu. Becasue the user/password info is in differnet databases, how can I call different validation scripts based on this input ?
See below please. Somethinglike this:
form.html: <form name="loginform" method="post" action="login.php"> <select name="loginform"> <option value="one">Section 1</option> <option value="two">Section 2</option> </select>
login.php:
@extract($_POST); if($_POST[loginform] == "one") {
echo "action = /forums/scc/dispatch.cgi/_admin/AVFLogin" NAME="LoginForm" > echo "<input type=hidden name="autologin" value="1"> "; echo "<input type=hidden name="formstyle" value="standard"> "; echo "<input type=hidden name="returnforum" value="_admin"> "; echo "<input type=hidden name="returnmsg" value="acahomepage"> ";
} else {
echo "action = /path to different cgi "; echo :different values for hidden fields".
}
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Form "action"
i am doing some php coding for my website. it is for a form inside "contact.htm" which directs the action to "process.php". the processing is fine as long as the validation of form is not passed. as soon as the validation is passed, the page will have to jump to another php page "thanks.php" along with the values from the previous form showing the user's input as an output. I tried to use header function but it is not passing the input values from the form. Is there any simple way to solve this problem without using javascript?
Parse Errors With "case "action":
I want to call an action that is in a file called "configm.php" but I get a parse error on line 8. (the bit that goes 'case "add":') Code:
Bizarre Phantom Bug (Calling A PHP Script From An Apache "Action" Directive)
I am using an "Action" directive in my Apache configuration to map a certain file type (by means of AddType and AddHandler) to a PHP script. I wasn't sure if this would work, since the Apache docs say the Action directive is for mapping a handler name to a CGI script in particular. But it seemed to work at first. Then a mysterious bug arose: Sometimes it works perfectly, and other times the output is a totally blank page. It seems that if I haven't viewed a page for a while, it chooses to do one of these at random (though it is blank more often than not), and then it persists in the same behaviour until I reload it many times. (That is, usually a page appearing blank will eventually display if I reload it many times; however, only rarely will a correctly-displayed page regress to appearing blank after reloads.) Checking with `curl -i', it would appear to a client program that the request was perfectly successful: all the headers are there (with the correct content-type), it has an HTTP/1.1 200 OK line, and so on (and there's nothing unusual in the server's access or error logs), except Content-length is 0, and there is indeed no content at all after the two newlines. WTF?? Since when do computers behave non-deterministically? I should hope, if a program is not going to behave correctly, that it at least do so predictably and consistently. That would make debugging it much easier. But what am I to make of this Schrodinger's Bug? How do I even approach the debugging process? (Also, if anyone could suggest a workaround, an alternate method of having a PHP script handle files with a certain extension, then that would be just as welcome. Though I'd like to stay within mod_php, avoiding a CGI-based technique, because I'd prefer to not start a process every time these pages are requested.)
"Action Canceled" Message From Browser?
Its very intensive and acts like it times out - im not sure, but doesn't come up with the timeout php error, but instead after loading for a bit: Firefox: It would prompt to be downloaded, not opened in browser. When opened its just a blank page. IE: "Action canceled , Internet Explorer was unable to link to the Web page you requested. The page might be temporarily unavailable." PHP file_get_contents: "Warning: file_get_contents(*url*): failed to open stream: HTTP request failed! in *script* on line x" Theres no headers on this script.
Populating "Month" Dropdown Menu
I can get the current month to display in a text box by inserting value="<? print strftime("%B"); ?>"> into the code for that particular text box on a form but how can I populate a drop down with names of all the months with the current one being 'default' as it would be in the text box example?
Check If $_GET["menu"] Is Null.
I'm using this code to see if is there any parameter for variable "menu": if($_GET["menu"] == "downloads") .... But this code log errors if there is no parameter passed (this heappens at the first time the page is loaded). I tryed this code: if($_GET["menu"] != ""){ if($_GET["menu"] == "downloads") ...
Action="<?=$PHP_SELF?>">
Can not determine how "<?=PHP_SELF?>" is supposed to work. The below is the line of code. <!-- <form name="search" method="post" action="<?=$PHP_SELF?>"--> When the above statement is run the following is the result. You don't have permission to access /dev/forms/forms_testing/< on this server.
Choosing A Host Based On Their PHP "security" Measures
just starting out learning about PHP, mostly by researching, installing and playing with different scripts. I am looking for a host that will provide the right environment for this - running a wide variety of PHP applications. I realise that security is also important, but for now flexibility is more important to me. Note that I'm **not** looking for people to recommend hosting companies, I have a good shortlist already. I'm looking for help in choosing between these, based on the configuration of their server environment. I would greatly appreciate your pointing out where my questions reveal my ignorance; if possible, help me fix up the questions and explain where I've gone wrong. Here is my understanding of these issues so far (assuming Linux/Apache): Running mod_php is less restrictive and therefore more flexible, and faster than running as CGI. More importantly, I've been told that mod_rewrite REQUIRES php running as a module, so on a host running CGI, I CANNOT get permalinks, pretty URLs, etc. Is this true? If so, then I definitely want a host running php as a module, even with the insecurity of 777/666 permissions. I should also ask the potential hosting services about my ability to put php configuration directives in custom .htaccess files (and not custom php.ini files, correct?) If this is the case, I assuem it becomes relevant to PHP what the server's AllowOverride is set to? I also understand that I should avoid choosing a host running php in safe mode.
How To Redirect Based On $_SERVER["HTTP_REFERER"]?
I have a page that I don't want anyone to be able to link directly to. The page should only be accessed from gatepage.php. I tried this code, but keep getting errors - "header info already sent", or something like that... Am I missing something, or is there a better way to do this? <?php $ref = $_SERVER["HTTP_REFERER"]; //echo $ref; if ( $ref == 'http://www.mydomain.com/gatepage.php' ) { //record visit } else { //send to gatepage.php header("Location:http://www.somegatepage.com"); exit; } ?>
How Do I Do Something Like $color = ("red", "yellow", "blue")[$colornum]?
How do I take an index of a literal array, instead of a variable? That is, say I want to get the short name of a month. Can I do something like: $monthname = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[$month]; or do I always have to do: $blah = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $monthname = $blah[$month]; It seems a shame to have to create a variable specifically for this one-shot purpose.
Change "From:" Portion Of Email
I created a Simple Feedback (mail) form in PHP, by following instructions in a book. It's pretty standard: User fills out form on website. Information gets send to mailbox. It works almost perfectly. The only thing I need to do is get the "From:" portion of the email to change to the users email address. Right now any email that comes from a form on the site has "mysite"@box143.bluehost.com as the sender. Its kind of like a default box or something. Anyway, Is there a standard command (i.e. $to = "", $subject = "") that I can use to change this like I did with the "Subject:"? Code:
Preventing Visitors Ability To "re-visit" A Page Via The "back Button"..
I have a rather complex registration/member sign up form.. which gets a little confused, when a visitor "backs" completely out of the form, then for whatever reason returns to the form. The form contains 'cancel' buttons, which naturally cancel the reg process and redirects them to the document just before they started. JS provides us with the "location.replace()" method, but I can't seem to find a way to coordinate the use of location.replace() with the posting of the form values. In short, I want to "replace" the first step of the form with the "second step". I think what's making this tricky, is that each step of the form are located within the "same" page (register.php). The document works like so: The first step is the "Member Agreement" when they click "agree" (submit) the system creates a new row in the temporary register table of the db. It then issues a registration cookie, which carries the row id, and session value. in addition (for those cookie impared users) we carry the row id and session value in hidden elements. So far, as long as the user continues through the process all is fine, but if they (for whatever reason) back all the way out, and click 'agree' again, the process fails. I guess I have to find a way to force a reload of the 1st step "if they've gone back" OR "replace()" the first step with the second, so as to prevent the user from going "back" to the 1st step of the register page.
Pagnation - Limit Number Of Pages Between "Previous" & "Next" Hyperlinks
Was hoping for some advice with a part of page navigation.... It works at the moment so there is a "Previous" & "Next" Hyperlink underneath the records. In between the Previous & Next links are the number of pages that there is of these records. e.g: Previous 1234 Next This is fine if there are only a few pages of records, but when there are hundreds of pages the numbers are listed and they take up half the web page with them. How can i make it so only limited 10 numbers of pages say appear between the "Previous" & "Next" Hyperlink and as you progress through the pages they are as do the next 10 numbers of pages? Code:
Using The Word "change" In Php...
Perhaps this is a silly question, but is the word "change" a php or MySql command? I had a script that wouldn't work with the a field called "change" in it, but when I removed that field it worked fine.
[regex] Stripping Out "name" And "value" Values Out Of Tags, Aaargh
Searched through the site, but couldn't find the right regex syntax I was looking for. the thing i want is, to extract with preg_match_all the given values in a tag... ex. $str = '<input type="text" name="name" value="value">' $pattern = some magic stuff I need to know preg_match_all($pattern, $str, $result); And in result I want to have the values text, name and value AND it's important that the order doesn't matter so structure of tags can be <input type =name= value=> or <input name= class= value= type=> etc, etc...
'Parse Error' Problem In "isset" And "empty"
I've been having some problems with a parse error that I can't figure out (PHP 4.3.11 on Solaris9). Sample code: <?php // getting strange parse errors on this class A { var $value; function A() { $this->value = 1; } function getValue() { return $this->value; } } $a = new A(); if (!empty($a->getValue())) { echo "success"; } else { echo "failure"; } ?> The result of this is: Parse error: parse error, unexpected '(', expecting ')' in /foo/public_html/parse_errors.php on line 15 I also get the same effect with "isset", however, testing with "is_null" or "is_int" produces the correct ("success"/"failure") result. Any ideas?
Echo "<!--#include File="top.html" -->";
I have a search script which returns a page of results, however I'd like the returned page to be in the same format as the rest of my site. To do this I've tried adding the HTML for my site to my PHP page with echo" " commands. This works for the plain HTML, but my regular pages also use SSI to do other stuff (some of them even execute other PHP scripts to generate tables of data etc). I've tried echo "<!--#include file="top.html" -->"; but it doesn't work as I get a parse error. My question is, how do I go about doing this properly? Is this possible at all? And if not have you guys got any suggestions to get around this?
Any File Size Limit In <PARAM Name="***" Value="***"> ?
I embed an applet in my php script which has a parameter providing an input file for the jar. Does this file has size limit? The code is as follows: <APPLET ARCHIVE="myapplet.jar" WIDTH=372 HEIGHT=360 VSPACE=0 HSPACE=0 ALIGN=middle> <?php echo "<PARAM NAME="data" VALUE="myfile.">";?> when "myfile" is beyond 15M, my applet cannot load sucessfully, but while this file is limited like 5M or 7M, it works well. Does anybody know is the reason caused by php script limit, applet mechanism, or by different browser?
How To Do PHP "require()" Or TCL "source" In Bash Script
I can't figure out how to explain this any better than this. In PHP we have a command "require()" that obtains a file and logically places it into another file. I cannot figure out how to do this in bash script as the requirement is necessary for a migration script to obtain the code from a .cfg file and then be able for the "parent" script to run the code it "imported" from the .cfg file, much like PHP's require() or TCL's "source". This is what I have so far and it fails: if [ -f ivc.cfg ]; then cat ivc.cfg fi Anyone really know bash script well please help, it's a barrier for me not to be able to get just this one piece working.
"Cannot Modify Header Information" With Large HTML FORM Options
I'm having some really odd behavior with a PHP script. I have it populating an HTML select form with a for loop. When I try the years 2006 to 1900. I get the following error: PHP Warning: Cannot modify header information - headers already sent by (output started at /Users/chrobb/Sites/city-directory/controlBar.php:54) in /Users/chrobb/Sites/city-directory/controlBar.php on line 88 I've done a fair amount of searching and it looks like this usually shows up when people have some extra whitespace after their closing PHP tags. Doesn't apply seem to apply here. When I crank the number down on the for loop to 94 iterations, the error goes away. Once I crank it up to 95, the error comes into play. So, it's tied to the output somehow. Looking at the raw HTML, there doesn't appear to be any significant difference between the version with 94 iterations versus the one with 95 iterations, except for the error and the failure of my script.
PHP Form Submission <input Type="hidden"> Security Issues?
Someone has said to me that when using a form (method = post), that storing data in "hidden" tags ie <input type="hidden" name="myField" value="something"> means that the user can set the value to whatever they like So my questions are: 1. How would they do this 2. How can I stop it 3. Do I have to abandon the hidden values and go with sessions?
Have To "actions" Or Run Two Types Of Queries (select,and Update) On The Same Form?
I had a brilliant idea on one of my pages that selects some data from my mysql database. I first set the page up to display some info and an image, just one item, with a row of data, etc. then I thought it would be nice to do a select, and perhaps an update (the title of the image) on the same page. I am wondering if I am having the wrong idea. I have a form, with two submit buttons, one selects an image, and some info. the other will update the image title for the given image (id, and p). I am seeing that I have a mistake here, since it seems the update query will run as well as when the select query is run (select button clicked). this overwrites my image titles in the db. I have the wrong idea, but have not seen how to do this "right". I could use another php page for update, but I am guessing this can be done from the same page. Below is my poor code - i am not an expert programmer!!! any help, suggestions will be helpful. <?php $img = $_REQUEST["img"]; $p = $_REQUEST["p"]; echo '<div class="input">'."".'</div>' //connection files for mysql @include 'c:/php/includes/db.inc' @include 'c:/php/includes/error.inc' //***@include '/usr/local/php/include/db.inc' //***@include '/usr/local/php/include/error.inc' //@require_once '/usr/local/php/include/size_image.php'
Problem With Enctype="multipart/form-data"
Hi, I am using a form to upload and image. I use enctype="multipart/form-data" in the form tag like this:- if(!isset($_POST['submitimage'])) .... <form action="<?=$PHP_SELF?>" enctype="multipart/form-data" method="post"> ............ else ............ This works fine in my local development environment on the PC but when I try using it on my host it fails. It seems that it simply doesn't recognise that Submit has been pressed as it simply re-enters the same piece of code and re-displays the form. If I take out enctype="multipart/form-data" then it does recognise that Submit has been pressed and executes the appropriate bit of code - but I get an error that there is no file (which is what I would expect). Could this be an environment issue with my host (why does it work in my local environment and with my host?)
How To Make A "sophisticated" Insert Record Form ?
I have a DB with many inter-related tables (MySQL) My main table called "content" has almost only foreign keys (integers) some have a 3 level relation (ex: content->city->region->country) I would like admins to be able to insert new records including all the "content" fields (in 1 page form) But how can I make an insert form that would display the related tables as list menus instead of a textfield with a number? (ex: select country from a drop down menu instead of typing the foerign key number) Main content Table: IDRef = primary key IDLocation = foreign key --related to tables city->region->country IDDescription = foreign key --related to table Description (=several big and small text fields) IDImages = foreign key --related to image (=image and thumbs path, alt text, etc..) Do you know any tutorial, help or solution ?
Suggestions Wanted Concerning Form Handling "template"
I am devising a php page that will handle a form submission, and wanted to know if anyone has already setup such an idea, or if you had links to point to good tutorials on this. Basically I have a form (which I use smarty templating to display, and smartyvalidator to validate). The php page basically is driven by the action variable (add, add_confirm, edit, edit_confirm, view, delete). When the form starts out, it is in view mode. Then if you click the add button, it switches to add mode. Confirming a new addition sends you into add_confirm (which would write to a DB, etc.). Edit would work the same way, except edit mode would lookup a record to display, edit_confirm would update that record, delete mode would delete, and view mode would basically display data (to edit/add/delete). Sounds easy, but my code is pretty long and I am looking to simplify this idea. Looking for how you all do this, and if anyone has a "template" setup to do this. Mine would be something like: if ($action == "view") { // do something ..... etc ....
Enctype="multipart/form-data"
after a server upgrade (to Apache 1.3.26 with PHP 4.0.3pl1) - PHP was not upgraded! - suddenly some forms stopped working. A form with enctype="multipart/form-data" will only work with the get method, but not with the post method. Using post, nothing will be passed. It is only a fancy page reload. No Variables, no values, nothing.
Passing Var With A Form "select" Type
i need to pass the choice of a form select to a page the form posts to "alllinks.php" <form name="viewby" method="post" action="alllinks.php"> i want to send a value that i can pick up as $admin_userid on the next page, is this correct for sending it? <option name="admin_userid">1</option> bit confused, i've done this before with "text" types but a select seems to be more confusing?
Adding "memory" To An Html Form Using Php
Is there anyway to retain the inputed information in a form? Example: I have 3 forms. (I am passing the variables from form to form using hidden variables, and the echo statment, thats not the problem) the final form contains the users name, address info etc. After the user fills out that form they come to a screen with all of there outputed info. I ask if there are any mistakes, if there are, the user either hits a back button or maybe a 'fix, edit' button. How do I retain the info on the form, so when the user does try to fix the error, all his info is still in place in the text fields in the form? Also, does anyone know of a 'canned' form validation script.
Saving An Image From A "file" Form?
How do I recieve a picture from a form off a website and save it to a directory? I use the "file" form to allow the user to browse their local drive but how do I get the actual picture so I couild use it later?
Error In Page When Checking Http_get_vars("myvar") And "myvar" Was Not Passed In URL String
PHP, coming from ASP coding if (HTTP_GET_VARS['b']==1){ print "Yes"; }else{ print "No"; } when "b" is not passed via (http://www.mydomain.com?b=1 an error occurs and the "NO" is printed but an error is printed too. How can I check for the value of "b" so that no error occurs if b is not passed?? example http=www.mydomain.com $myvar=HTTP_GET_VARS['b'] causes an error because "b" does not exist (ie. its not passed in the URL string. $myvar maybe evaluated as NULL or Empty but the error is printed in the page, anyway.
"Remember" The Values On A Form
how to get your code to remember what the user typed in after they click back when using sessions. Right now, if the user fills out the form and submits it to find an error, then when they click back all the fields are empty because I am using sessions. Does anyone know of the line of code or the tutorial that will refill the fields with the values?
In Email Form How Do We Say "must Be Equal To X"?
we are getting a lot of spam through our PHP Feedback form, and have set up a new field 'prove you're human', asking them to do some simple maths. What is the command for the PHP script itself, to say "this field must be equal to 9 or return the error page"?
What Should I Use To Set Up Modified "Calendar" Form?
I have events that take place every Monday, Wednesday, Saturday, and Sunday, and I want to generate my copy--which is the same for most events--and my printed schedule from a php form. My plan is to first generate a form that lists pulldown boxes for each of those days in the next month--I could specify the month, but I don't think that fits my bill, and then utilize the pulldowns to set the events. However, I'm not sure where to begin to return just the days I need...should I use getdate() as my basis for this? From what I'm reading, it seems right, but I'm not sure.
"post Comment" Form
How do I make it possible for people to post comments to my web site like you do on a blog?
Coding "NEXT" And "PREVOIUS" Buttons
Hi I am stuck here. I am doing a form which dispalys details of client companies. My query includes this statement: .... WHERE CompanyName LIKE %$name% .... What I need is following: if a query returns more then one result I what to "flip" through result with NEXT and PREVIOUS buttons.
Mysql/php - "LIMIT" And "ORDER"
In the following fragment of code, I am querying a database that in order to display a list of films. The list is very long and I would like to offer the possbility to restrain the range of results showned by page keeping in mind that the user should be able to browse forward or backward data if applicable. I know that I have to add the LIMIT method in the MySQL query but I have a hard time figuring how not to get lost in setting it dynamically in the PHP script. Then I have a second question. Is there a more elegant / straightforward way to deal with the display order of the data (cf. $ot, $od and $oy)? Code:
Sticking "if" Or Changes Within A MySQL "where" Array?
I'm not exactly sure how to even ask the question, and I know my terminology is not good as I'm a SQL beginner, but, here goes. I need to find a way to make an if statement within an array...or, the "while" portion of a recordset. The best way I can ask is show what I mean. http://oscarguy.mechphisto.net/awardbrowse.php If you go there and select an award (like Best Picture), leave the year field alone, and select YES and submit, you'll see a lot of results. And I have HR's dividing each entry. What I need to do is group all the entries of the same year, or at least only put HR's between the blocks of years. So, I'd have all the entries for 2002, an HR, then all for 2001, an HR, etc. Here at the bottom I'll include my PHP code I'm using so far. But I have no idea where to even start looking for an answer...if it's even possible. If someone can just give me the name of the function or process or technique, then I can go Web/book searching myself...I just need a direction of where to go. PHP:------------------------------------------------------------------------ ------ $query_RS_award = "SELECT * FROM $award WHERE id != Ƈ' ORDER BY year DESC, w DESC"; //$query_RS_award = "SELECT * FROM $award WHERE year = "$year""; $RS_award = @mysql_query($query_RS_award, $connection) or die("Couldn't query: " . mysql_error()); $totalRows_RS1 = mysql_num_rows($RS_award); while ($row_RS_award = mysql_fetch_assoc($RS_award)) { $award_id = $row_RS_award['id']; $award_tblid = $row_RS_award['tblid']; $award_award = $row_RS_award['award']; $award_year = $row_RS_award['year']; $award_category = $row_RS_award['category']; $award_won = $row_RS_award['w']; $award_film = $row_RS_award['film']; $award_nominee = $row_RS_award['nominee']; $award_note = $row_RS_award['note']; if (!($award_category)) { $award_category = "n/a"; } else { $award_category = $award_category; } if ($award_won == "1") { $award_won = " - Award Winner"; } else { $award_won = ""; } $display_block_Award .= "YEAR: <span class='normalText12White'>$award_year</span><br>FILM: <span class='normalText12White'>$award_film</span><br>CATEGORY: <span class='normalText12White'>$award_category</span><br>NOMINEE: <span class='normalText12White'>$award_nominee</span><span class='normalText12BoldWhite'>$award_won</span><br><blockquote><span class='normalText12White'>$award_note</span></blockquote><hr>"; }
Cookies And "include" Or "require"
i'm having a problem with my setcookie() instructions. Although there are absolutely no html tags in front of them,for some reason PHP3 sends me back the message "oops...php3_SetCookie called after header has been sent"... I do however use two "require" calls, one to a file with a .php extension, and one to a file with an .inc extension. At the beginning of each files there's a Could the cookie failure and the include functions be related ? In my text, I have even wiped out any HTML tags such as "bold, paragraph, line break" tags, even in "echo" commands, but to no avail what am i doing wrong ?
FTP_login + $pass="" And $user=""
I use the following scrit in an Intranet with the user name = "" and the password = "" : <?php $ftp_server = "192.168.25.25"; $ftp_user = ""; $ftp_pass = ""; $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { echo "Connected at $ftp_user@$ftp_server "; } else { echo "Can't connect with $ftp_user "; } ?> I have the following message : Connected to 192.168.25.25 Warning: ftp_login(): 'USER': Invalid number of parameters in E:www est_ftp.php on line 26 I tried to : ftp_login($conn_id, "", "") but i have the same result...
Why Use "Stripslashes" And "Addslashes" Function
Can someone let me know why one would use strip slashes or add slashes functions. I know what they do but cannot see the exact use for them e.g. if i have a textfield and encase it in an stripslashes function, it will escape any back slashes etc...
PHP Form Using "Textarea"
I am trying to add a textarea to a PHP form to query for House Numbers in a database. I was able to make this work with just a text field but need to allow my users to input several House Numbers in one query. Code:
Dropdown Menu <selected Name="...
I have a dropdown menu like this one: <select name="country" tabindex="6" id="select_country"> <option value="">- Country List -</option> <?php $query = "SELECT * FROM country ORDER BY country ASC"; $result = mysql_query($query) or die('Error, query failed'); while ($row = mysql_fetch_array ($result)) { $country = $row['country']; ?> <option value="<?php echo $country ?>"><?php echo $country ?></option> After I have selected one country and I hit the submit button it go back to the default value in the box, what I want is to show the selected value in box until I selected another value. If the default value is Australia when I start this page, I then select USA and hit the submit button it reset to the default value "Australia", but I want it to show USA as long I not select anything else. I have tried to use session in selected="<?php echo $_SESSION['country']; ?>" but it didnt work.
|