473,326 Members | 2,048 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,326 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 2087
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.