Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Passing Value To Function From Html Page Using If...else Statement


I am confused about passing a value to a function from an html page using the if..else statement.

I have tried searching for the php syntax for function calls with an if...else statement but have been unsuccessful. I have provided my code (which is wrong of course) Code:




View Complete Forum Thread with Replies

Related Forum Messages:
Changing An If Statement To Html Page
How do I change the following code from my process page to a new page with the detials on it. I made a html page cut and pasted it into this spot but it did not work. What do I need to change in order for it to be a html page is shows. Code:

View Replies !
Passing A Parameter From An HTML Page To A PHP Page
I want to pass a language value (EN/FR/DE etc.) from an Index HTML page to a PHP page with a language code in the call, so that the PHP page can select texts in that language. I would like to to it from an unordered list item if possible by extending the link ... <li><a href="scripts/pricelist.php???>Pricelist[/url]</li>

View Replies !
Can You Redirect Every Existing Html Page Through A Php Function?
Is there a way to redirect every single page on an existing web site through
a php function?

In other words, say I have a whole functional HTML web site, never written
to use any php. Now I would like to have a php function handle displaying
every page, for example, instead of:

http://www.mysite.com/mypage.html

you would call:

http://www.mysite.com/dopage.php?p=mypage.html

....and then the php could do some fancier includes at the end of each page,
etc., or add a header, etc.

I don't want to rewrite the whole site and rename all the pages; also, this
site has been around for awhile and there are a lot of links floating around
the internet to direct urls on the site, so I'm wondering if I can intercept
every URL to that site and redirect it to the php function, which will then
open the page.

View Replies !
Passing String Problems To SQL Statement
I'm using php as my server side script. When I pass a certain string var that contains the char = ' An error occurs My SQL statement is;

Quote: $SQL = "SELECT n.tDate, c.CDNum, c.CWID, l.LessonTitle FROM CDInfo c, Lesson l, Num n WHERE l.LessonCode = c.CWID AND n.CDNum = c.CDNum AND l.LessonTitle = '$Title' ORDER BY n.tDate, n.UniqueNum ASC";

If my $Title = Vino's Dream World an error occurs bcos it only takes the val Vino and omits the remaining words.

View Replies !
IF Else Statement - Form Being Submitted From Another Page And Being Directed To A Second Page
I have a form being submitted from another page and being directed to a second page. In this form is a checkbox called nonprofit. When checked the value is 1.

On the second page I have the following code:

View Replies !
Passing Variable To A Function - Value Is Not Accessed Inside The Function
i am extracting a data from the url. www.somesite.com/somefile.php?usrname=hello
i had extracted hello from this url by using $var=$_GET['usrname']; i passed this $var as a parameter in a function $var.But that value alone is not accessed inside the function why?

View Replies !
Wrapping If Statement Around HTML
I need to wrap an if statement around a group of php/html and don't know how to go about it. I need to make the following chunk of code display based on the if statement below: Code:

View Replies !
Simulating Include Statement With Html Only
Is there a way to simulate the php include() statement in html that does not require php but only html?

I have a bunch of html files that all have the exact same navagation coded into each file. I want to move the navagation code to one file and then include it into the html as the page is requested.

I have done this sucessfully in the past by inserting an include() statement inside php tags and running the html page through the php interpeter.

Problem is that in this case I don't think that the host will let me run those html files through the php interpeter.

I have looked around in html at some of the tags that are not sure as much and as yet havn't found a way.

View Replies !
Does Php Work With OnClick In An Html Input Statement?
Does php work with onClick in an html input statement?

<HTML>
<input type="button" name="add_picture" value="Add another picture"
onClick="<?php picture_count(); ?>">

I want to call the function picture_count() when button labeled "Add another
picture" is clicked in HTML

I do not want to use submit in place of button since I do not want to submit
the form at this time.

With the above statement, I receive an error expected ";" and the function
is not called.

View Replies !
If Statement In Function
in that function i have an if statement to decide what email address that email should be sent to. the problem is i cant see the email address outside of the if statement when i echo it. am i meant to be able to see it? if not then how do get to see it? if so then take a look at my code n see if you can tell whats up. Code:

View Replies !
Function Like A Conditional Statement
how to use the function which works like a conditional statement.

I think it is something like: 3 < 4 : $something ? $something

View Replies !
IF Statement Within Echo Function
On my edit page, I'm using dropdown boxes to select the day, month, and year, that the event date needs changing to.

My problem is, I'm using loops to display the days, but how can I do it so if the loop counter equals the day, the option appears selected on the page.

I therefore have an if staement when I'm echoing out the options, and if the counter equals the day, the selected attribute is echoed out into the option, so it appears selected. Code:

View Replies !
Passing Variables From Page To Page
I just need to know how to pass variables from page to page on my form.

View Replies !
Passing Variables From A Page To An ASP Page?
I have a site using a PHP CMS and I need it to use an ASP module from
another site but I would like to use a frame so it looks like it is
still in the same site.

I need to pass a username variable from a form in in the PHP webspace
(where the domain is pointing) to a page in an ASP webspace (using a
subdomain not related to the main domain).

I created a frame page in the php hosting with a 1px top frame and the
main frame pointing to the asp page but of course the variable is not
being passed.....if I put the ASP connection code on the frameset page
it doesn't recognize it because the hosting is a Unix/PHP hosting
only.

My question to you is:

Can a variable be passed from the php to the ASP webspace using some
other technique?

I just need to have the ASP module showing as if it is in the PHP.

View Replies !
Passing Parameters From HTML To PHP
I am so thick heading but I do not
understand why this failure.

I have put in some 'printf' statements for debugging and some comments.
And some questions.

From the menu.html page

<html>
<a href="guestbook.php?var1=list-PINSS.txt"><h3>Padre Island National
Sea Shore</h3></a><br>
<a href="guestbook.php?var1=list-LHL.txt"><h3>Light House
Lakes</h3></a><br>
<a href="guestbook.php?var1=list-7LD.txt"><h3>7 Lakes Damon</h3></a><br>
<a href="guestbook.php?var1=list-GR.txt"><h3>Guadalupe River</h3></a><br>
</html>

To the PHP file
<?php

include $_GET['var1']; //prints to screen the correct information
$file=$_GET['var1'];

printf("-----%s", $var1); // prints nothing.
printf("+++++%s", $file); // prints to the screen the correct information.

error_reporting(1);
$mode=$_GET['mode'];
if($mode!='view' && $mode!='sign') $mode=$_POST['mode'];
if($mode!='view' && $mode!='sign') $mode='sign'
$name=$_POST['name'];
$site=$_POST['site'];
$phone=$_POST['phone'];
$date=date('l, F dS, Y (g:i A T)');
$self=$_SERVER['PHP_SELF'];
printf(;// prints to the screen the correct information.
($handle=fopen($file,'a+') or die("Could not open file: $file"));// FAILS
....................
....................
?>

View Replies !
Passing HTML In A Form
What I am trying to do is pass HTML through a form in PHP. The form has to be in PHP format because I am really passing varables that have HTML in them.For example:

<font color="green">This is green</font>

Then when I assign the following: PHP Code:

View Replies !
Passing A Variable To HTML
I have a standard HTML page. After user authetication, i would like to send the user name from MySQL Database to The standard HTML page. The new HTML page will display the name of the user and the common contets for the user.

View Replies !
Passing Info From Html To Php
I'm trying to pass info from a "Drop list" in an .html form into a .php which will then query a database. It doesn't work and I wondered if I'm missing something easy?

If I junk the dropdown list and just put a "textfield" there is no problem but I want to have the fixed choices list. Here is the code:

View Replies !
Passing Parameters To Php/HTML
how to use MySQL so my questions are mostly on PHP area. I would like to have a form where people can enter their username and I will and return the items that they own.

What I know is: First I need an HTML page with a form where they will enter the username in which I will put the code:

View Replies !
Passing HTML Into A File
I have some php code that generates an iframe inside my current page.  http://.../noc/test/gage_test2.php?iSize=500&dSetting=.99&sDisplay=bleh

iSize is the size of the iframe dSetting is the value a decimal representation of a precent, and sDisplay is a string representing text that is displayed in the iframe. 

With common strings everything is great i just get in a jam when i pass in some html.  i.e. i want to be able to pass in something like this <a href="bleh.htm">bleh[/url].  is there any way around this? Code:

View Replies !
<link:page.html,xxx> => <a Href="page.html?id=xxx">
I want to transform this code <link:page.html,xxx> to

<a href="page.html?id=xxx"> dynamically.

I tried out alot of preg_replace stuff, but I didn't get to manage it.

View Replies !
On If Statement Open .htm Page?
how to open a preset page from an if statement, such as:

if ($row["password"]==$password ) {
printf("Successfully Logged In!");
}else{
print("Login failed!");}

where instead of just printing the text string it opens a new page!!

View Replies !
Reloading A Page In IF Statement / PHP
if ( $turns == 0 ) {}

if i wana reload a page if this statement if true, with out the user havign to click any thing how can this be done?

i tried

if ( $turns == 0 ) {
header('Location: main.php');
die(); }

it doesn;t seem to be working]

View Replies !
If Statement - Page = Index
What I'd like to do is, on my website on the initial page, the index, I don't want to link back to the index to be a link. If there is a:

If page = index then link not enabled
else link enabled

sort of possibility in php.

View Replies !
Redirect To Another Page With If Statement
I was hoping to get a little help structuring a script that I'm trying to devise. I'd like an if statement that basically says: If there is no ZipCode in the current record in the database, then go to the ZipCode entry page, otherwise keep loading the current document.

View Replies !
Verify With An If Statement What The Page Url Contains.
I am trying to verify with an if statement what the page url contains.

View Replies !
Page Redirect From Within If Statement?
I would like to have users login, and based on this login, if they're one type of customer I want to take them to pagex.php, if they're another, I want to take them to pagey.php.

Since I don't know what type of customer they are until they've logged in, I can't redirect with the header function, so I thought maybe I could do it by grabbing their login info, and seeing if they're type x, then go to pagex.php if they're type y, go to pagey.php: Code:

View Replies !
Can A Control Statement Go Within A Mail() Function?
I would like to put an IF statement within the mail() function. I've
tried this and searched around but haven't found anything written
about this. Is it possible? I've been doing somethings like :

mail ("Email", "Subject", "Body".if() {...}."", "From");

Sorry if this is a dumb question. BUT, if it works I will try similar
things in SELECT statements.

View Replies !
Problems With Return Statement In Function
Today I faced a problem where I am very confused and I could not
solve it and I am posting here....

My question is
Is is possible to return a value to a particular function

............

Below I have give a detailed description on why this question
appears to me.

Consider the following Code.

function one()
{
$ret_val = three();
echo "<br>RetVal:=".$ret_val;
}
function two($a,$b)
{
echo "<br>I am In function ".__FUNCTION__."()";
if($a==$b)
return true;
else
return false;
}
function three()
{
$array_one= array(1,2,3,4,5);
$array_two= array(1,2,3,4,5);
$a = array_rand($array_one,1);
$b = array_rand($array_two,1);
if(two($a,$b))
{
$ret_val = "$a and $b are equal";
echo "<br><br>I am In function ".__FUNCTION__."() and the
Val is $ret_val<br>";
return $ret_val;
}
else
{
three();
}

}

View Replies !
Function Usages In Query Statement
I'm trying to get the result of the functions below to appear in my query statement. My listall() function seems to be working but why not the other two? When I debug I get the listall() function value to appear but the other values stay blank. Code:

View Replies !
Passing Variables Into Html File
My mailer uses $html = $mail->get_file('example.html'); to send an already made up html page. Problem is, I need to pass variables in to the html before it's sent.

View Replies !
Passing Datetime Through Html Form
I am writing a script that allows my client to update live events that he will be playing at, for the table i have made in mysql i have used datetime to hold this value as both a date and a time need to be passed. what is the best way of making sure that a user enters these values in a correct manner and then combining these values to become one variable. i was thinking that a select menu would be best as that way the client cannot make mistakes, and making one select menu for date and one for time.

Would this be the best way ??, how could i append the date variable to the time variable??
if a select menu is the way to go does anyone know of a script i can use to save me having to hard code the whole thing myself.

View Replies !
Passing Array As Value Of A Variable (PHP & HTML)
I am developing a web site which requires a set og unique values be
transferred between pages and server many times. There fore i decided
to put the values in an array so that only one reference to the array
is needed ratherthan idividual reference. The situation is like this:

When the page is loaded based on the user input say 6 values are
created like character1="tom", character2="jerry", Character3="micky",
Character4="donald", character5="cat", character6="rat". This to be
preserved for two or three further pages to be loaded based on further
user input. One solution is to create <input>tags with names
Character1, character2, ............character6 and assign values to
each of them. But when the list is enlarged say to 75 values it is
unweildy. So I found that when the page is first created an array is
created like $character=array('tom', 'jerry' , 'micky', 'donald',
'cat', 'dog')and can be assigned to a single input tag. Is it possible
to such a tag like "<input type="hidden" value=$character>". Or is
there any better alternative to this ?

View Replies !
Passing Variables From HTML Forms
I'm using Apache 1.3.27 as a local host to develop my site offline, since I only have a 56k and cant be online all the time. The problem is that when I try to pass variables from a HTML form to a php file, it doesnt recognise the variable names here are the lines of code concerned: on the HTML form:

<input type="text" size="16" maxlength="20" name="email">

in the php file:

print ("Your email address is $email");

It works when hosted online, but not when offline i've turned global variables ON in php.ini, but that didnt help can anyone else suggest anything?

View Replies !
Passing Array From To Html-code
How do you pass an array from PHP to html-code?

My way to do this is to pass the array as a string to a formfield and then use javascript to put the values into an array. Is this a good method?

I've seen some coders suggest to use the htmlspecialchars-function combined with serialization. Does anyone have an example for how to do this?

What is the better way to do it? What is the most secure?

View Replies !
If Statement With Page Location (not A Redirect)
I have a menu that will swap with our login if now logged in. I can't just "take out" the menu code from update.php because of use of common headers. but on this page it's causing problems with our updating program, (can't handle the extra text fields on page).
looking for a something like Code:

View Replies !
Reload (refresh) Page Within An If Statement
Is there a simple way in php to reload a page coded within an if statement.(see code below)It's very important that the session stays intact. Code:

View Replies !
Web Page Open Up Automatically Using An If-statement
I was wondering if there was a way to have a web page open up automatically using an if-statement, either as a pop-up or just going to the page in the current browser window?

View Replies !
Can I Get The Value From An Assoc Array That Is Returned By A Function...in One Statement?
I want to be able to get the present year in one statement. I know that I can do it this way:

$y = getdate();
echo 'year='.$y['year'];

But, I want to do something like:

echo 'year='.getdate()['year']; # BAD, I know

Ideas?

View Replies !
Simple If Statement - If Term Starts With Aa Then Use Function New
I'm trying to say: if term starts with aa then use function new. i tried following unsuccesfully:

if(ereg("^aa", $term)) {
$new...
}

and

if(term == "^aa") {
$new...
}.

View Replies !
Embed Php Generated Html In Another Html Page
I am trying to include some php generated html in a page that is just a standard html file, NOT a php file. I have seen other html pages do this by including an src to the cgi script in script tags, like this:

<script src="http://someurl.com/somescript.cgi"></script>

the html page loads and the script is executed and the returned html is displayed in the calling page. So, I tried this:

<script src="http://someurl.com/somescript.php"></script>

It doesnt work!!

View Replies !
.html' Page Be Replaced By '.html.php'
Can a '.html' page be replaced by '.html.php' page via RewriteRule? To clarify, I'm using a software that formats the look of the site using .html pages. I'd like to add PHP code to that page but of course, it is not of the right page type.

What I was wondering is Could I create a duplicate of that '.html' page, rename it to .g. '.html.php' and make the revisions and then just create a RewriteRule that redirects the '.html' page to the '.html.php' without generating an error?

The alternative and undesired way of doing it would be to rename the original page to '.html.php' and find and revise ALL of the routines that call that page. That would create a revision nightmare especially upon upgrading the software.

View Replies !
Checking Html Checkbox Status After Passing It
What's the code for checking wheter a checkbox has actually been checked when passing it to a form handler with the post method?

View Replies !
Variable Passing To Script To Fill Html
I'm trying to do the above in order to process an image and return the
result to an html image control. It fails and my key suspects are either
the variable that I'm passing in - ImageName - for processing, or the return
data which is done (or not as the case may be) by imagejpeg($img) in the
script, after header("Content-type: image/jpeg").

View Replies !
Passing PHP Variable Into An Html Text Field
I am working on a flatfile configuration program and I need to read a single record csv file into php and pre-load the values into html text boxes. I have the file reading part working with 6 variables $field1 through $field6. When I am done, I then save the form back to the same file. This allows a configuration file to be updated from the web.

View Replies !
Passing HTML In Hidden Input Field
I just wanted to take a poll to see what the best way to pass a chunk of text containing HTML in a hidden input form element would be. I'm trying to pass the text from one page to another to another in a content management scenario, but the whole thing breaks down when HTML enters the picture. On the page where the value is pulled from the database into a textbox, I'm using:

<?
  <textarea cols="45" rows="10" name="blurb">".$blurb."</textarea>
?>

On the next page, the user can review the code displayed as plain text using:

<?
  echo(nl2br($blurb));
?>

There are no problems so far. But at the bottom of that page in the form that will pass the variables on to the script that will write the final changes to the database, everything falls apart when HTML comes into play.

<input type="Hidden" name="blurb" id="blurb" value="<? echo $blurb; ?>">

This line made everything fall apart when I put an anchor tag into the text. The closing > made it think the tag itself had closed, and the link text started printing to the screen.

So, what's the best way to handle situations like this. Would I use htmlentities() to get it to the database writing script and the use html_entity_decode() when actually passing the values into the db? Or is there a more sublime solution?

View Replies !
Passing A Value From A Function To Another One
I have two function. The first one select all the link in the DB with the id, here's the code:

while($row = mysql_fetch_array($result)) {
if ( $i % 5 == 0 ) {
echo '</td><td valign="top">'}
echo '<a href="realisation.php?site='.$row['id'].'">'
echo $row['name'];
echo '</a><br />'
$i++;}

The second function select * in the DB where the id = the $site in the first function, here's teh code for the second function:

$query = "SELECT * FROM portfolio WHERE id = '$site'";
$result = mysql_query($query, $conn) or die ('ERROR '.$query.' '.mysql_error());
while($row = mysql_fetch_array($result)){
echo $row['description'];}

The probleme is when i click on a link nothing happen, like if the value of $site was equal to nothing, if i make an echo of $site in anyplace in the function i have no result, my link are like this "realisation.php?site=1"

View Replies !
Passing To Function
I have created a function that accepts a dynamic number of arguements and while it works, I'm wondering if I am passing it data in a correct format.

I call the function as so

myFunction($myArray, a, b ,c);

a, b and c are elements in $myArray... Is the above syntax incorrect?
Should I use

myFunction($myArray, "a", "b" ,"c");

in order to be more correct? I'm afraid that while it works now, some minor bug fix later might prove to be a show stopper for me.

View Replies !
How Do I Return 10 Results Per Page Using SELECT Statement?
I'm wasn't sure whether to post this under the PHP or under the MySQL section of the forums. Since most people (I'm assuming) who write PHP script, also use MySQL, I thought I'd stick with PHP. I'm rather new to both PHP and MySQL and I'd be very grateful to anyone who can help me solve a problem I'm having at the moment. First, I'll give you an introduction to my little project...

I'm developing a database in MySQL that is used to store the song titles of all the MP3s I have on my PC. I've written a basic search feature that works well. The user has 2 options: Either he can type a special "!ALL" "parameter", that I made up, to return all the songs in the database or the user may enter a few characters in the textbox and select "song title" or "artist" etc. from a dropdown to search for a specific song title or artist etc.. Hope you are following so far? Say for example the user presses submit after typing "!ALL" to return all the song titles - there could be hundreds of results. What I want to do now is display 10 results on a page, then on the next page another 10, etc. (like a real search engine!). I've tried doing it with the LIMIT statement, but like I said I'm new to this and discovered that that is not the right way of going about it. My question is this: how would I go about returning 10 matches per page? Do I use hidden form fields? What would the SELECT statement look like? What would the PHP scripting look like to setup the "back" and "forward" navigation between the result for the search?

View Replies !
Redirect To A Page Based On The Results Of An If Statement
I want to redirect to a page based on the results of an if statement. I have: PHP Code:

<?php
if (empty($vat_number)) {
echo "VAT number is empty"; /redirect to page1.php
} else {
echo "The VAT number is $vat_number"; /redirect to page2.php
}
?>

Does nauone know the best way to do this.

View Replies !
Page Redirection - Link Index.html Page To A .php Pag
I have an index.html page with a link to a .php page This is the complete code of the .php page Code:

View Replies !
Passing Value To Different Page
i have a page home.php which has a dropdown menu for the user to select an institution and a Go button. once the user selects an option, a new page named institution.php will be opened which will display information about the institution which was selected previously.

i do not want to have different pages for each institution, so that's why i have one page to display the information according to the option selected in home.php. the problem is, when the user selects an option and click Go, the institution.php doesn't show any data from the db about the institution selected, not even the images that i have. can anyone tell me what's wrong? Code:

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved