Jump to content


Photo

Anyone so kind as to help?


  • Please log in to reply
7 replies to this topic

#1 Captain Salad

Captain Salad
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 23 March 2006 - 08:40 PM

Hi, would it be possible for one of you geniuses to give me a little hand with this script, this is my fist PHP script and am really stuck on the radio and tick box parts, if I don’t click on the tick boxes or radio buttons the script goes no where, I would like my user to have the option of NOT clicking the radio or check box if the so decide and the form to go through fine, could anyone amend the below script so I can see where I was going wrong?

Thank you for your time and god bless

$creditcard is the one which uses a tick box and $transfer is the one which uses radio button, the rest are just normal form fields

<?
$transfer = $_REQUEST['transfer'] ;
$email = $_REQUEST['email'] ;
$existingnumber = $_REQUEST['existingnumber'] ;
$pacnumber = $_REQUEST['pacnumber'] ;
$title = $_REQUEST['title'] ;
$firstname = $_REQUEST['firstname'] ;
$middleinitial = $_REQUEST['middleinitial'] ;
$lastname = $_REQUEST['lastname'] ;
$dob = $_REQUEST['dob'] ;
$currentaddress = $_REQUEST['currentaddress'] ;
$town = $_REQUEST['town'] ;
$postcode = $_REQUEST['postcode'] ;
$residentialstatus = $_REQUEST['residentialstatus'] ;
$yearsataddress = $_REQUEST['yearsataddress'] ;
$monthsataddress = $_REQUEST['monthsataddress'] ;
$previousaddress = $_REQUEST['previousaddress'] ;
$previoustowm = $_REQUEST['previoustown'] ;
$previouspostcode = $_REQUEST['previouspostcode'] ;
$hometel = $_REQUEST['hometel'] ;
$daytimetel = $_REQUEST['daytimetel'] ;
$bankaccountyears = $_REQUEST['bankaccountyears'] ;
$bankaccountmonths = $_REQUEST['bankaccountmonths'] ;
$creditcard = $_POST ['creditcard'] ;


if (!isset($_REQUEST['email'])) {
header( "Location: [a href=\"http://www.brittalk.com/brittalk/Templates/contactUs.htm"\" target=\"_blank\"]http://www.brittalk.com/brittalk/Templates...actUs.htm"[/a] );
}
elseif (empty($email) || empty($transfer) || empty($title) || empty($firstname) || empty($middleinitial) || empty($lastname) || empty($dob) || empty($currentaddress)
|| empty($town) || empty($postcode) || empty($residentialstatus) || empty($yearsataddress) || empty($monthsataddress) || empty($hometel) || empty($daytimetel)
|| empty($bankaccountyears) || empty($bankaccountmonths)) {
header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
header( "Cache-Control: no-cache, must-revalidate" );
header( "Pragma: no-cache" );
?>

<html>
<head><title>Error</title></head>
<body>
<h1>Error</h1>
<p>
Oops, it appears you forgot to enter some information into the required fields.
The required fields are identified by a red star preceding them. Please press the BACK button on your browser
and try again.
</p>
</body>
</html>

<?
}
else {
mail( "bukem_1@tiscali.co.uk" , "Unlock Customer Phone.",
"Transfer an existing mobile number from another network: $transfer
Existing Number: $existingnumber
Pac Number: $pacnumber
Name: $title $firstname $middleinitial $lastname
Date Of Birth: $dob
Current Address: $currentaddress $town $postcode
Residential Status: $residentialstatus
Years At Current Address: $yearsataddress
Months At Current Address: $monthsataddress
Previous Address: $previousaddress $previoustown $previouspostcode
Home Telephone Number: $hometel
Day Time Telephone Number: $daytimetel
Had Bank Account for: $bankaccountyears $bankaccountmonths
Own A Credit Card?: $creditcard

",

"From: $email");
header("Location: [a href=\"http://www.mysite.com");\" target=\"_blank\"]http://www.mysite.com");[/a]


}
?>


#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 23 March 2006 - 09:17 PM

A couple of techniques for you

If you have radio buttons, either set one of them 'checked' by default

<INPUT TYPE='RADIO'  name='rb' value='1' checked> 1
<INPUT TYPE='RADIO'  name='rb' value='2'> 2
<INPUT TYPE='RADIO'  name='rb' value='3'> 3

or add a hidden field with same name and value=0 before the buttons

<INPUT TYPE='HIDDEN'  name='rb' value='0'>
<INPUT TYPE='RADIO'  name='rb' value='1'> 1
<INPUT TYPE='RADIO'  name='rb' value='2'> 2
<INPUT TYPE='RADIO'  name='rb' value='3'> 3

then you still gat a value for 'rb' even if no button is selected.


With checkboxes, only checked ones are posted so if you have checkbox named creditcard

$creditcard = isset($_POST['creditcard']) ? $_POST['creditcard'] : 0;

Now you have a 0 value for creditcard if it isn't checked.

hth
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 Captain Salad

Captain Salad
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 24 March 2006 - 09:52 AM

Hi, thank you very much for trying to help me, I edited the code for the check box but now get this message Parse error: parse error, unexpected '?', expecting ',' or ')' in W:\Webspace\resadmin\ajsimpson\simputers.co.uk\www\brittalk\Templates\Scripts\tmobilecontract.php on line 24

here is the script:, any ideas?

<?
$transfer = $_REQUEST['transfer'] ;
$email = $_REQUEST['email'] ;
$existingnumber = $_REQUEST['existingnumber'] ;
$pacnumber = $_REQUEST['pacnumber'] ;
$title = $_REQUEST['title'] ;
$firstname = $_REQUEST['firstname'] ;
$middleinitial = $_REQUEST['middleinitial'] ;
$lastname = $_REQUEST['lastname'] ;
$dob = $_REQUEST['dob'] ;
$currentaddress = $_REQUEST['currentaddress'] ;
$town = $_REQUEST['town'] ;
$postcode = $_REQUEST['postcode'] ;
$residentialstatus = $_REQUEST['residentialstatus'] ;
$yearsataddress = $_REQUEST['yearsataddress'] ;
$monthsataddress = $_REQUEST['monthsataddress'] ;
$previousaddress = $_REQUEST['previousaddress'] ;
$previoustowm = $_REQUEST['previoustown'] ;
$previouspostcode = $_REQUEST['previouspostcode'] ;
$hometel = $_REQUEST['hometel'] ;
$daytimetel = $_REQUEST['daytimetel'] ;
$bankaccountyears = $_REQUEST['bankaccountyears'] ;
$bankaccountmonths = $_REQUEST['bankaccountmonths'] ;
$creditcard = isset($_POST['creditcard'] ? $_POST['creditcard'] : 0;

if (!isset($_REQUEST['email'])) {
header( "Location: [a href=\"http://www.brittalk.com/brittalk/Templates/contactUs.htm"\" target=\"_blank\"]http://www.brittalk.com/brittalk/Templates...actUs.htm"[/a] );
}
elseif (empty($email) || empty($transfer) || empty($title) || empty($firstname) || empty($middleinitial) || empty($lastname) || empty($dob) || empty($currentaddress)
|| empty($town) || empty($postcode) || empty($residentialstatus) || empty($yearsataddress) || empty($monthsataddress) || empty($hometel) || empty($daytimetel)
|| empty($bankaccountyears) || empty($bankaccountmonths)) {
header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
header( "Cache-Control: no-cache, must-revalidate" );
header( "Pragma: no-cache" );
?>

<html>
<head><title>Error</title></head>
<body>
<h1>Error</h1>
<p>
Oops, it appears you forgot to enter some information into the required fields.
The required fields are identified by a red star preceding them. Please press the BACK button on your browser
and try again.
</p>
</body>
</html>

<?
}
else {
mail( "bukem_1@tiscali.co.uk" , "Unlock Customer Phone.",
"Transfer an existing mobile number from another network: $transfer
Existing Number: $existingnumber
Pac Number: $pacnumber
Name: $title $firstname $middleinitial $lastname
Date Of Birth: $dob
Current Address: $currentaddress $town $postcode
Residential Status: $residentialstatus
Years At Current Address: $yearsataddress
Months At Current Address: $monthsataddress
Previous Address: $previousaddress $previoustown $previouspostcode
Home Telephone Number: $hometel
Day Time Telephone Number: $daytimetel
Had Bank Account for: $bankaccountyears $bankaccountmonths
Own A Credit Card?: $creditcard

",

"From: $email");
header("Location: [a href=\"http://www.brittalk.com/brittalk/Templates/thankyou.htm");\" target=\"_blank\"]http://www.brittalk.com/brittalk/Templates...you.htm");[/a]


}
?>

thank you and god bless

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 24 March 2006 - 09:58 AM

Sorry, I omitted closing ")" on the isset() function


$creditcard = isset($_POST['creditcard'][!--sizeo:3--][span style=\"font-size:12pt;line-height:100%\"][!--/sizeo--][!--coloro:#FF6666--][span style=\"color:#FF6666\"][!--/coloro--])[!--colorc--][/span][!--/colorc--][!--sizec--][/span][!--/sizec--] ? $_POST['creditcard'] : 0;
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 Captain Salad

Captain Salad
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 24 March 2006 - 11:37 AM

Wow, works like a charm, thank you sincerely for you help and patience with me, it is very appreciated!

Could I pick your knowledgeable brain on one more bug?

Using my current script I want to make the $transfer radio buttons a require field, when I try this with the current code, when filling out the form, if I miss the $transfer radio buttons out the browser displays an error message. Any help on this other bug?

Thank you again for your time and help!!

God bless


#6 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 24 March 2006 - 11:44 AM

Have you used one the methods for radiobuttons that I gave in my first post?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#7 Captain Salad

Captain Salad
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 24 March 2006 - 01:57 PM

Have now, again works like a charm ;) thanks very much. Just so I know how would the same work for checkboxs? Put in a hidden checkbox perhaps?

#8 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 24 March 2006 - 07:35 PM

Radiobuttons and checkboxes are different animals. Radio buttons only ever have a single value. With checkboxes you can have multiple values so it isn't going to work in quite the same way.
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users