Assign A New Value To A Variable Passed From An Html Form
I'm trying to assign a new value to a variable passed from an html form to a php3 script. I'm using an if statement to evaluate variable 3 to see if it is equal to a specific string, if it is I'm reassigning variable 2 to be variable2+variable 3.
if ($question3!="select days")
{
$question2=$question2+$question3;
}
This is the statement. It keeps giving me a parse error and I can't seem to find the right documentation to show me how to combine two string variables.
View Complete Forum Thread with Replies
Related Forum Messages:
Assign Variable To A Block Of Html Code
Is it possible to assign variable to a block of html code? Something like this : $myblokvar = "<table width="487" border="0" cellspacing="0" cellpadding="0"> <tr> <td><table width="487" border="0" cellspacing="0" cellpadding="0"> <tr> <td><img src="images/bartitle_login.gif " alt="Login" width="475"...
View Replies !
Assign Value To Variable
Is there any way I can use a function to create a variable and assign a value to it? I have a Perl script that returns some LDAP information: sn=Shore givenname=Mike logintime=20041008153445Z logindisabled=FALSE Instead of parsing this text and assigning the values, I was wondering if a function exists where I can pass a variable name and a value, and the variable would be created. ie. somefunc("sn", "Shore") Would create the variable $sn and assign the value "Shore" to it.
View Replies !
Assign To Variable
I am trying to take data from the database and assign it to a variable but i'm not sure how this is the code ive been trying $sql = "SELECT Name FROM Names WHERE Name = 'Peter'"; while($row = @mysql_fetch_array($sql)) { $var == $row['Name']; }
View Replies !
Is It Possible To Assign A Whole Function Or Block To A Variable ???
Is it possible to assign a whole function or block to a variable ??? eg. <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> <? if (db_num_rows($qid_p) == 0) { ?> <li>No <? } ?> <? while ($prod = db_fetch_object($qid_p)) { ?> <p><b><a href="product_details.php?id=<?=$prod->id?>"><? pv($prod->name) ?></a></b> <br><? pv($prod->description) ?> <br>$<? pv($prod->price) ?> <br>[<a href="cart_add.php?id=<?=$prod->id?>">+ Add to Cart</a>] <? } ?> How to assign this code to a unique variable ???
View Replies !
Assign Function Output To Variable??
I've found some references to this topic at : http://forums.devshed.com/showthrea...ion+to+variable but it does not seem to be working for me. here's a snippet... <? PHP function listPeople ($getArray) { foreach ( $getArray as $val ) { echo "$val, "; } } $foo = listPeople($splitDirector); ?> The function works, and as you can see i'm simply trying to assign the output of the function to $foo. But instead, the output is written to the page where I assign it... like a print or echo statement, and the variable $foo is empty.
View Replies !
Ways To Assign A Value To A Session Variable.
I am wandering which way to assign a value to a session variable exist. Which of the following examples will work. Example #1: session_start(); session_register("ex"); $ex = 2.0; Example #2: In first.php: session_start(); session_register("ex"); In second.php: $ex = 2.0; Example #3: In first.php: session_start();...
View Replies !
Assign Variable From Database Field
Is there a way to assign a variable from a database field? I'm thinking along the lines of $make = $row_rsList['make']; $model = $row_rsList['model']; then they'll switch out based on my SQL WHERE statement. This valid syntax?
View Replies !
Assign Userid To A Session Variable
When a user logs into my system, i assign their userid to a session variable [php] $_SESSION['userid'] = $myrow[0]; [php] and then a user logs out, i do the following [php] $_SESSION['userid'] = '' session_write_close(); [php] so, when a user clicks on a link to a page they should only see when logged in, i do the following test [php] if (isset($_SESSION['userid'])) { header('Location: members.php3'); } [php] but the logout does not seem to work for some reason? userid still seems to be set after running the logout script, any ideas? am i doing something silly?
View Replies !
Variable That Holds A Html Form Name
What variable holds the form name when the contents of a html page is submitted to a .php page? I used the post method to send the forms results to the php page. My php script looks like this: $CName= $HTTP_GET_VARS["form name"]; This is incorrect. There must be a specified variable in .php that holds the name of the form. My html form line looks like this: <form name="Theory" method="post" action="http://www.mysite.com/JSl/Jschool.php4">
View Replies !
HTML - Hidden Variable Within A Form
I have a problem making PHP work to its full. i have installed php 5.x version, apache 1.3.x ver and mysql 3.x version all of them are working fine. i have a problem.... when i pass any hidden variable within a form like in the code below Code:
View Replies !
Multi-Dimensional Arrays - Assign Variable
It's a simple question, but I'm just not getting it. I have two files: <?php $precinct = array ( array ( number=>2324, centerlat=>-122.31705665588379, centerlong=>47.710367959402525, etc... <?php include ("precinctdata.php"); $filename = $_GET['id']; $number = $precinct[filename-1][number]; etc... I want to assign the value of "2324" to the variable $number. I've done this with arrays that start with number=>1, 2, 3, etc., but not successfully with specific values. What am I missing?
View Replies !
Assign MySQL Function Result To PHP Variable
I know to use: mysql_fetch_row($result) to convert a row from a SQL query result set into an array for use with PHP. but in the case of SQL queries that return one value, such as calls to MySQL functions, is there another PHP mysql api function I should use. For example, right now I use a "workaround" technique from PHPBuilder: $result=mysql_query("SELECT COUNT(*) FROM tablename"); list($numrows)=mysql_fetch_row($result); Rather than using this "workaround" code is there a way to simply assign the result of the MySQL function query to a variable. $result=mysql_query("SELECT COUNT(*) FROM tablename"); $numrows=mysteryfunction($result);
View Replies !
HTML Variable In Auto Response Form
This formmail works. Auto responds fine. When I change the $my_message variable, from what is listed, to HTML code, it cancels out the latter PHP code(which is the autoresponder). The HTML code I insert into the $my_message variable, includes Javascript functions, which I assume are causing problems with the PHP, because when I remove the JS function, the "color code" in my editor, looks normal, with the latter PHP coding back in place, but it still doesn't work. Basically, I'm just trying to figure out how to autorespond an HTML email instead of just Text. Code:
View Replies !
Referencing PHP_SELF Variable Within HTML Form - Problem...
I am developing a simple web site that contains a form page. The apps utilized are apache 2.0.48, php 4.3.4 on redhat 8.0. I have built a simple web form with one text box and a submit button. The result of pressing the submit button should be php echo'ing the input back to the screen. Attached is the tiny code snippet below: ---------------------------------------------- <html> <head><title>PHP Forms Example</title></head> <body> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST"> Type a string: <input type="text" name="myString"><br> <input type="Submit" name="submit" value="Submit Journal"><br><br> </form> <?php print "You typed: $myString"; ?> </body> </html> ---------------------------------------------- The problem I am experiencing is that the print statement doesn't print anything back to output. If you notice, I changed the reference PHP_SELF due to 4.2.x modifications in php.ini.
View Replies !
Variable Passed In Through Header
We recently upgraded PHP and variables that were once passed through the URL are no longer recognized. Example: http://www.sun.com/test.php?defectID=2 Within the test.php code: <?php session_start(); $defectID = (int)$defectID; if ( $defectID != 2 ) { // This should not execute, but does. echo "Error: $defectID"; exit; } ?>
View Replies !
Variable Passed From One Script To The Next?
I'm trying to have a variable passed from one script to the next, and I need to do it without including it in the url (via the ?variable='value'). The variable is populated in the first script when a person logs in, and if they are a supervisor the variable $isallowed is set to true. If they are not a supervisor $isallowed is set to false. The variable needs to be passed to a couple different pages that need to check and see if the person trying to access the page is logged in and a supervisor.
View Replies !
How To Retreive Url Passed Variable?
I am having a problem retreiving a variable that has been url-encoded from a previous php href link. I have a script that passes a variable, but is it doen right? And, how do I get the variable in the new page? The code is as follows for the passing: Code:
View Replies !
Retrieveing Info Passed From Html
i have a flash banner on a page that when clicked sends the browser to another page. This banner is linked to a php file that counts the amount of clicks on the banner. In the html page for the flash banner I have: Code: <embed src="swfs/banner1.swf?clicktag=forms/tracking/bannertrace.php&clickheader=http://www.somewebsite.com" width="570" height="80" align="middle"> in my php file I have: PHP Code: <?php $traceFile = "banner/clicktrace.txt"; $clickURL = $_GET(clickheader); $fh = fopen($traceFile, 'r'); $theData = fread($fh, filesize($traceFile)); fclose($fh);$fw = fopen($traceFile, 'w'); $theData = $theData+1; fwrite($fw, $theData); However the clickheader variable that contains the URL does not get passed to the php file.
View Replies !
Hiding Passed Variable In The Address Bar
when i pass values from the link like this <a href="reservation.php?myseldate=1".'-'.$month_curr.'-'.$year_curr."">Click here</a> then in the address bar it shows http://localhost/pankopat/reservation.php?myseldate=1-9-2007 if the user alters the value of date and change 1-9-2007 to 2-9-2007 (or any other thing) then that value gets saved in the database.. Is it possible to hide this value in the address bar or make it uneditable..
View Replies !
Variable Being Passed From Site Into PhpBB
I am creating an autologin feature where my site members are logged into the bulletin board automaticly the only variable I find that is global is $sAuth it stores the members id #... I can user this to pull the name and password out of the database and set name and password in the forum to eaqual these... is this a security issue? or can $sAuth only be set by script on my site??? I am rather new and want to make sure this variable can not be asigned in another way.
View Replies !
Showing A Different Page When A Variable Is Passed
this is the code i have just now <? include 'code.php' ?> //where variables are kept <? $welcome = $_REQUEST['welcome']; $leave = $_REQUEST['leave']; if ( $welcome ) echo $page['welcome']; if ( $leave ) { echo $page['leave']; { } else { echo $page['redirect']; }?> what i want to do is, if the variable passed is "welome" i want it to show a welcome page and if "leave" is passed i want it to show a leave page, and when no variable is passed i want it to redirect to a totally different page like this: index.php?welcome Show welcome page index.php?leave show leaving page index.php redirect to a different page
View Replies !
Passed Variable Not Working In An If Statement
I am setting up a website where students can login and browse their course information and handouts. I have set up a database with there courses in and have managed to get each students courses to appear after they have logged in correctly. The course shows as a hyper link and is passed to a page where an if statement checks which course it is and then directs them to the relevant page. Code:
View Replies !
How To Extract Variable Passed With Get Method
I want to extract the variable below and assign it as $bActive = $_Get["name"]; Something is just not working as $bActive produces an empty array. Please help. Quoteecho " <td><input type="checkbox" name="active_".$key.""value="active"";Thanks.
View Replies !
Ensure A Variable Passed Through Through URL Exists?
It just donned on me that I need an error message if someone tries to go to a page with a variable in the URL that doesn't correspond to a database entry. For example, http://www.domain.com/poetry.php?piece=4 does not yet exist. Say I only have three poems in the database right now. What are some ways (or the best way) to make sure the variable leads to content or to otherwise display an error message?
View Replies !
Passed Variable Names In A Function
I am trying to write a function to check for invalid entries in a form. What I want to do is echo an error message with the variable name that is in error. Like so: Code: function nodata($fieldname) { if(strlen($fieldname) <= 1) { echo 'You must enter a value for $fieldname<BR>' return true; } } When I run this I just get: You must enter a value for $fieldname. Is there a way I can can get: "You must enter a value for $username" if I passed the variable $username into the function.
View Replies !
Variable Not Passed To Mysql Query
It seems that my code as below is not passing the variable content to my WHERE clause in my MySQL query. If I do an echo on it, the value displays, but when I look at the query using echo "Query: $q"; my value is empty. Code:
View Replies !
Variable Passed In GET Or POST Array
This has created a situation that I am not sure how I should handle. I have scripts (pages) that can receive an input variable from the POST array (initial entry) or it could be in the GET array (go back and re-edit a form, for instance.) Code:
View Replies !
Assign Variable Name As Variable
I want to be able to create a foreach loop that will go through all the intended POST variables and then assign it as a standard variable. For example, I want to have $username = $_POST['username'] without even knowing username exists in the context of the foreach loop. Code:
View Replies !
Variable Passed Through A Function Error - Driving Me Crazy
I have a file that contains a form and passes the results of that form through this function. The function parses the form, checks the fields for content, then enteres the information into a database. Everything is working until I apply the $tblname variable as one of the variables in the function. It is not used anywhere else and for some reason when I change the actual table name to this variable, it is not inserting into the table (I tested the query and there is no table name defined).
View Replies !
Encrypting Variable Values Passed Thru A Link In A Web Page
I am working on a project in PHP / Mysql on linux platform. The project has a login page where any registered user is supposed to login before he/she can have access to some major functionalities in the project. Since I need to check the authenticity of the user in other secured pages, I have to carry forward the username with which he/she has logged. As I am doing so, the username is appearing in the url. This of course is a major security lapse.
View Replies !
Image Upload - Using A Variable Passed From A Flash Page
i'd like to pass a variable using post into the following form (that is from php.net) using a variable passed from a flash page (i'm competent in flash but a novice in php)how do integrate: $folder = $_POST['folder']."/"; into the form so that when submit occurs the folder path is passed to upload.php : <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="upload.php" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input type="hidden" name="MAX_FILE_SIZE" value="30000" /> <!-- Name of input element determines name in $_FILES array --> Send this file: <input name="userfile" type="file" /> <input type="submit" value="Send File" /> </form>
View Replies !
Variables Not Passed From Url Or Form To Page
I use a Mac at home running OSX 10.2, and use the Apache PHP MySQL trio for developing and testing sites. I've had very good experiences with this setup and have had no major problems till now. I noticed recently that variables added to the end of the url (the get method, ...url/page.php?var=value) are not passed to the script within the page. Forms using either the get or post method have the same problem. For example, a page named "foobar.php" containing this: Code:
View Replies !
Values In Form Not Passed Using Onclick ?
i have a php file name main.php i want to do a post and not a get since this action is to delete a row in the database. however, when i try to do a href onclick, the values are not passed to the main.php. why ? Code: echo "You have " .$votesattach. " votes for this quote. Delete the Quote and Votes ?"; echo "<form name=send1 method=post action=main.php?action='deleteit'>"; echo "<input type=hidden name=action value=deleteit>"; echo "<input type=hidden name=which value=$delete>"; echo "<input type=hidden name=userno value=$userno></form>"; echo "<a href=main.php onclick=document.send1.submit()>YES</a>";} how do i do pass values to the server using a post method ?
View Replies !
When A Value Passed In Form Or Q'string Is Empty..
I am trying to figure out how to deal with when not all elements in a submitted form are filled out or when page expects a query string and doesn't get one.. I tried the two conditionals below, but still got errors: $param= $_GET['msg']; /* if ($param != "") { echo $param; } */ if (isset($param)) { echo $param; } query string is: home.php?msg=selected records have been deleted from the database. (referrer pg is not always pg sending query string.. so need to deal w/when no query string is passed..)
View Replies !
PHP Not Populating Form Variables Passed Through POST Or GET
I"m running: Windows Xp SP2 Apache2 PHP5 MySQL4 Everything seems fine and dandy, and I can do scripting on server side, but for some reason I cannot get data from a form to be put into a variable. I have a simple form in an html page which submits, and in the php script that handles the input, none of the data in the form is going into the variables. My php.ini file does have all the GPC's in place(ie variable_order, the way they get processed).
View Replies !
Hitting Back, Form Info Not Passed On
I have a form that will retrieve information from a database based on variables passed in a link. Order=17 would pass on the order number which is used to connect to a MySQL database. Now, if I hit back on a browser after opening one form page up already and click on a new link, say &order=18 the form will load blank without anything filled in, so basically it seems like it didn't connect to the database or didn't make use of the order=18. I call upon these using a GET method. Here's something that me be of issue, the form is filled in if this condition is met: if ($_GET['firstTime']='YES' && $_SESSION['second']!= 'true')
View Replies !
Using Includes: Html Form Parse Data Inside 2nd Form.
i'm coming down the stretch, so to speak. i've got a lot of the separate things settled that i need for my main "date entry" form. due to the several data items which need to be collected by this form, i've decided to try using includes, which i've found isn't that tricky at all really. however, one of my includes needs itself to parse it's own little form data to result in the final entry to be submitted in the "date entry" form. perhaps doing this particular bit as an "include" is NOT the best option? Code:
View Replies !
Add Form Field Values Into Php Seesion Variable Before Submitting The Form
I have php page which is basically a simple html form containing some text fields.The user will type in values in it and submit it .Now what i want is that just at the time of submittion i want to assign the form field values in session variables. I nwwd this b'coz the form is being submitted into a cgi script which has been given to me.Now the cgi script is an executable one and i am unable to view or change its content,Its functionability is to change a password for a linux user account .Now the cgi script after completing the job is redirected to another html page.What i have to do is that i need to trap the user input and update the values in a mysql database .Now if i can assign the values in a session variable then i can do the updatation from some later pages.
View Replies !
|