473,226 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

Simple PHP problem - passing arguments to another script

Hi,

I'm total php newbie and probably have trivial problem.

I have following two scripts. First creates web form and should run second
script with two arguments. But those two arguments don't get to second
script, cause this line

print "Please enter both phone number
and name!";

is always executed and incoming arguments are empty.

What is wrong ?

Thanks in advance,

regards,

Rob.

== cid-form.php ==
<html>
<head>
<title>Asterisk Caller ID form</title>
</head>
<body>
<h1>Asterisk phone book</h1>

<form name="EntryForm" action="cid-store.php" method=POST>

<table cellpadding=2>
<tr>
<td>Phone number:</td>
<td><input name="PhoneNumber" size=30></td>
</tr>
<tr>
<td>Name:</td>
<td><input name="PhoneName" size=30></td>
</tr>
<tr>
<td></td>
<td><div align=right>
<input type=submit value="Save">
</div></td>
</tr>
</table>

</form>
</body>
</html>

== cid-store.php ==
<HTML>
<HEAD>
<TITLE>Storing Asterisk CID data</TITLE>
</HEAD>
<BODY>
<h1>Asterisk phone book</h1>
<?php
set_time_limit(5);
if ($PhoneNumber <> "" && $PhoneName <> "") {
// Note: this PHP script runs as user "apache"!
// system("whoami > /tmp/info");
system("sudo /usr/sbin/asterisk -rx " . escapeshellarg("database put
cidname $PhoneNumber \"$PhoneName\"") . " &> /tmp/error");
print "Successfully stored <b>$PhoneNumber</b> as
<b>$PhoneName</b>.";
} else {
print "Please enter both phone number and name!";
}
?>
</BODY>
</HTML>


Jul 17 '05 #1
6 2085
Heres the error:
if ($PhoneNumber <> "" && $PhoneName <> "")

refering to the POST variable just as $ and then the name of the form
field is obsolete. It was removed in newer versions of PHP for
security reasons.

Instead, put:
if ($_POST("PhoneNumber") <> "" && $_POST("PhoneName") <> "")

$_POST is an array on any page reached from a form with method="POST"
By the way, it would probably be better to check that they have entered
something in both form fields on the cid-form.htm page. This way,
their browser doesn't erase what they have typed in when they press the
back button. Then on the PHP page, put:
if (isset($_POST("PhoneNumber")) && isset($_POST("PhoneName")))

the isset() function returns false only if the variable doesn't exist;
it returns true for a variable that exists, but has no content, like
"". This way you can have a different error message for people who try
to access cid-store.php by typing it directly into their browser, or
from their favorites or history.

Jul 17 '05 #2
I noticed that Message-ID:
<11*********************@z14g2000cwz.googlegroups. com> from DJ Craig
contained the following:
Instead, put:
if ($_POST("PhoneNumber") <> "" && $_POST("PhoneName") <> "")


Not sure if round brackets work (never tried) but it's certainly more
normal to use square. I always use single quotes too.

And if one is set, they both will be. If you need to check if anything
has been entered you need to use empty()
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3

"DJ Craig" <sp**@djtricities.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Heres the error:
if ($PhoneNumber <> "" && $PhoneName <> "")

refering to the POST variable just as $ and then the name of the form
field is obsolete. It was removed in newer versions of PHP for
security reasons.

Instead, put:
if ($_POST("PhoneNumber") <> "" && $_POST("PhoneName") <> "")

$_POST is an array on any page reached from a form with method="POST"
By the way, it would probably be better to check that they have entered
something in both form fields on the cid-form.htm page. This way,
their browser doesn't erase what they have typed in when they press the
back button. Then on the PHP page, put:
if (isset($_POST("PhoneNumber")) && isset($_POST("PhoneName")))

Hi,

thanks for hints. I followed you instructions and put
if (isset($_POST("PhoneNumber")) && isset($_POST("PhoneName")))

but now I get error :

Parse error: parse error, unexpected '(', expecting ',' or ')' in
/var/www/html/database/cid-store.php on line 11

Any further advice ?

Regards,

Rob.
Jul 17 '05 #4
I noticed that Message-ID: <ta*******************@news.siol.net> from
Robert Rozman contained the following:

"DJ Craig" <sp**@djtricities.com> wrote in message
news:11*********************@z14g2000cwz.googlegr oups.com...
Heres the error:
if ($PhoneNumber <> "" && $PhoneName <> "")

refering to the POST variable just as $ and then the name of the form
field is obsolete. It was removed in newer versions of PHP for
security reasons.

Instead, put:
if ($_POST("PhoneNumber") <> "" && $_POST("PhoneName") <> "")

$_POST is an array on any page reached from a form with method="POST"
By the way, it would probably be better to check that they have entered
something in both form fields on the cid-form.htm page. This way,
their browser doesn't erase what they have typed in when they press the
back button. Then on the PHP page, put:
if (isset($_POST("PhoneNumber")) && isset($_POST("PhoneName")))

Hi,

thanks for hints. I followed you instructions and put
if (isset($_POST("PhoneNumber")) && isset($_POST("PhoneName")))

but now I get error :

Parse error: parse error, unexpected '(', expecting ',' or ')' in
/var/www/html/database/cid-store.php on line 11

Any further advice ?


Here is a script I wrote earlier as part of a tutorial
http://www.ckdog.co.uk/phpcourse/2_c...structures.doc

It should give you an idea.

<html>
<head>
<title></title>
</head>
<body>
<?php
//let's catch all errors
error_reporting(E_ALL);

//if there is no input, display the form
if(!isset($_POST['send'])){
?>
<form method="POST" action="">
Enter Forename: <input type="textbox" name="forename" value="">
<br><br>
Enter Last name: <input type="textbox" name="lastname" value="">
<br><br>
<input type="submit" name="send" value="Send"><br><br>
</form>
<?php
}

//if there is input but either forename or lastname is empty

elseif(empty($_POST['forename']) || empty($_POST['lastname'])){
print "Please enter both a forename and a last name<br>";
print "<a href=\"".$_SERVER['PHP_SELF']."\">Back</a>";
}

//if there is input and neither value is empty
else{
print "Forename: ".$_POST['forename']."<br>";
print "Last name: ".$_POST['lastname'];
}
?>

</body>

</html>

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #5
Robert Rozman wrote:
"DJ Craig" <sp**@djtricities.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Heres the error:
if ($PhoneNumber <> "" && $PhoneName <> "")

refering to the POST variable just as $ and then the name of the form
field is obsolete. It was removed in newer versions of PHP for
security reasons.

Instead, put:
if ($_POST("PhoneNumber") <> "" && $_POST("PhoneName") <> "")

$_POST is an array on any page reached from a form with method="POST"
By the way, it would probably be better to check that they have entered
something in both form fields on the cid-form.htm page. This way,
their browser doesn't erase what they have typed in when they press the
back button. Then on the PHP page, put:
if (isset($_POST("PhoneNumber")) && isset($_POST("PhoneName")))

Hi,

thanks for hints. I followed you instructions and put
if (isset($_POST("PhoneNumber")) && isset($_POST("PhoneName")))


DJ Craig did some typos. The line above should read

if (isset($_POST["PhoneNumber"]) && isset($_POST["PhoneName"]))

as noted by Geoff Berrow.

but now I get error :

Parse error: parse error, unexpected '(', expecting ',' or ')' in
/var/www/html/database/cid-store.php on line 11

Any further advice ?

Regards,

Rob.

Jul 17 '05 #6
My bad...
but if u use double quotes u can put variable names in the quotes like
echo "You have $lives lives left.";

Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Brian Sabbey | last post by:
Here is a first draft of a PEP for thunks. Please let me know what you think. If there is a positive response, I will create a real PEP. I made a patch that implements thunks as described here....
1
by: Joe | last post by:
I am trying to write a Perlscript to be used with some HTML pages. Here is how it works: 1.. The first HTML page has a form which requests for user input. Then it passes the QUERY_STRING...
7
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. ...
11
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
27
by: one man army | last post by:
Hi All- I am new to PHP. I found FAQTS and the php manual. I am trying this sequence, but getting 'no zip string found:'... PHP Version 4.4.0 $doc = new DomDocument; $res =...
13
by: aum | last post by:
Hi, I'm a Python programmer, just starting to get into javascript. On reading some of the js guides, and not liking any of the OO usage patterns I saw, I've cooked up something which python...
8
by: Jon Harrop | last post by:
I am trying to learn C# and .NET programming in general but I am finding it very hard going. To start with, I'd like to translate some trivial functions from other languages that I am familiar with...
3
by: vijayarl | last post by:
Hi all, i have perl script, which is used to send mail. its a command line utility. if we run this perl script in command line by passing all it's required arguments, it works very well.there no...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.