Can someone tell me what I am doing wrong?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Skrilla
Forum Newbie
Posts: 9
Joined: Sun Apr 25, 2010 11:26 am

Can someone tell me what I am doing wrong?

Post by Skrilla »

I am currently in school taking a .net developers course and have done an intense 6 weeks of C# and im into my 2nd week of VB.. we are doing asp next and then on to databases.
My thing is I have not done anythig in asp yet and have built an online form using a php and I'm afraid I am not familiar enough with the language yet to understand how to spit my data out to the user properly.

What I need to do is very simple.. I need to check my checkboxes on my form to see if they are checked, asign the value to a variable and then echo a string to be sent to my email.
No need to post the entire page of code so I will just show the part I need help with.

Here is where I am checking the checkboxes:

Code: Select all

<?
if ($_GET[Licensed_Mortgage_Broker_Y] == checked)
{
	$Licensed_Mortgage_Broker == "Yes";
} else
{
	$Licensed_Mortgage_Broker == "No";
}
if ($_GET[Licensed_Real_Estate_Agent_Y] == checked)
{
	$Licensed_Real_Estate_Agent == "Yes";
}
else
{
	$Licensed_Real_Estate_Agent == "No";
}
?>
And later I want to spit the data out:

Code: Select all

$message = "Response for $recipientname:
		Brokers Name: $Name
		Title / Owner: $Title
		Email: $Email
		Company Name: $Company
		Mailing Address: $Mailing_Address
		Telephone: $Telephone
		Fax: $Fax
		Licensed Mortgage Broker: $_POST[$Licensed_Mortgage_Broker]
		Licensed Real Estate Agent: $_POST[$Licensed_Real_Estate_Agent]";
I am simply experimenting with the GET and POST keywords.. I have no idea if I am doing this right.
Everything is being sent but the variables $Licensed_Mortgage_Broker and $Licensed_Real_Estate_Agent are not showing any data

Please help me :0 it's driving me nuts and I am tryin g to get it done quickly so I can get back to studying for my weekly vb tests lol
Last edited by Benjamin on Mon Apr 26, 2010 2:34 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
dimxasnewfrozen
Forum Commoner
Posts: 84
Joined: Fri Oct 30, 2009 1:21 pm

Re: Can someone tell me what I am doing wrong?

Post by dimxasnewfrozen »

Simplest example:

Code: Select all

    <?php
	
    echo $_POST['box']; 
	
	?>
	<form method="post" action="<?php $_SERVER['PHP_SELF']; ?>" />
   		Check Me <input type="checkbox" name="box" id="box1" value="Yes"/><input type="checkbox" name="box"  id="box2"  value="No"/>
  	  <input type="submit" />
    </form>
    

Skrilla
Forum Newbie
Posts: 9
Joined: Sun Apr 25, 2010 11:26 am

Re: Can someone tell me what I am doing wrong?

Post by Skrilla »

I ended up figureing it out.. im still having problems with my submit btn though.
viewtopic.php?f=1&t=115736

It will not let me use my own image for some reason. the default submit btn works fine though ;/
davex
Forum Contributor
Posts: 101
Joined: Sat Feb 27, 2010 4:10 pm
Location: Namibia

Re: Can someone tell me what I am doing wrong?

Post by davex »

Hi,

Checkboxes either provide their value if set or nothing at all.

Code: Select all

<input type=checkbox name=mycheckbox value=1> Check Me
Will pass a variable of mycheckbox with a value of 1 only if checked

Code: Select all

<?php
if ( isset($_REQUEST['mycheckbox']) && ($_REQUEST['mycheckbox']==1) ) echo "Was Checked";
else echo "Was NOT Checked";
?>
Is how I would handle the processing normally.

HTH,

Cheers,

Dave.
Skrilla
Forum Newbie
Posts: 9
Joined: Sun Apr 25, 2010 11:26 am

Re: Can someone tell me what I am doing wrong?

Post by Skrilla »

ty guys.. I still have this issue with the submit btn though.. could absolute positioned divs being used to hold all my fields be causing an issue?
again you can see the original post by clicking the link above
davex
Forum Contributor
Posts: 101
Joined: Sat Feb 27, 2010 4:10 pm
Location: Namibia

Re: Can someone tell me what I am doing wrong?

Post by davex »

Hi,

Just looked at your original post and didn't see anything about a submit button problem.

Are you sure that all your inputs are in the same <form> container?

Please post your form HTML for us to have a look.

Cheers,

Dave.
Skrilla
Forum Newbie
Posts: 9
Joined: Sun Apr 25, 2010 11:26 am

Re: Can someone tell me what I am doing wrong?

Post by Skrilla »

I just figured it out.
I was using:
<input type="image" id="submit" value="Submit" src="images/Send.jpg" name="submitform">
and it didnt work

but used:
<button type="submit" name="submitform" value="Submit" style="border: 0; background: transparent; cursor: pointer;">
<img src="images/Send.jpg" />

and now it works :/

Ill be happy to get some time when im done with my course to really take a look at php
Thx guys :)
Post Reply