Jump to content

Recommended Posts

Hello folks!

 

as I stated in my previous post I am a php newb and trying to learn slowly but surely.

 

I'm creating a simple forms page and having trouble getting the output. here is the code....

 

<form id="form1" name="form1" method="post" action="">
  <label for="textfield">credit score:</label>
  <input type="text" name="creditscore" id="creditscore" />
  <p>
    <label for="submit"></label>
    <input type="submit" name="submit" id="submit" value="go" />
  </p>
</form>

 

That's for the first page...

 

<?php
$creditscore = $_POST['creditscore'];
echo "{creditscore}:";
?>

 

what i'm trying to do is have user enter their number in the box,click go and retrieve the result in the next page. when I test it to see if it works,it just shows the forms page again.

 

can someone tell me what i'm doing wrong and how can I fix the problem? Again I only been playing with php for 2 weeks now so i'm still trying to learn.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/175525-cant-figure-out-simple-forms-code/
Share on other sites

post what you have. if you have the following

$creditscore = $_POST['creditscore'];
echo $creditscore;

then it will do what you want it to.

 

I noticed that you have no action set on your form. Is the above code on the same page as the form code? If not you will have to set the action to the location of the above code. for instance if the above code were on page.php, the form would look like

<form id="form1" name="form1" method="post" action="page.php"><?php //Right here is what i changed ?>
  <label for="textfield">credit score:</label>
  <input type="text" name="creditscore" id="creditscore" />
  <p>
    <label for="submit"></label>
    <input type="submit" name="submit" id="submit" value="go" />
  </p>
</form>

 

I noticed that you have no action set on your form. Is the above code on the same page as the form code? If not you will have to set the action to the location of the above code. for instance if the above code were on page.php, the form would look like

 

THIS!

 

Thanks a lot for your help Mike.Problem is solved!

 

I use dreamweaver to make the form for me and completely forgot to enter where the action is going.very much appreciated. Hope to become an expert like you guys soon!

If you would like the value to be pass onto the next page, you can use session variable for that. Ex:

 

$_SESSION['name']=$_POST['name'];

 

tried it out and worked also! thanks guys.very helpful.you'll be hearing from a lot in this forum lol so brace yourselves.  :D

I noticed that you have no action set on your form. Is the above code on the same page as the form code? If not you will have to set the action to the location of the above code. for instance if the above code were on page.php, the form would look like

 

THIS!

 

Thanks a lot for your help Mike.Problem is solved!

 

I use dreamweaver to make the form for me and completely forgot to enter where the action is going.very much appreciated. Hope to become an expert like you guys soon!

 

No offence or anything like that. But if you really want to learn better, I suggest you get rid of DW. Start cofing with some decent editor that has php syntax highlighting and start doing some small projects bit by bit and making sure that you understand always every part that you write. Then when feeling comfortable set some little harder/bigger goals. I really don't think that DW is very good way to learn coding. Also it generates poor code.

I use dreamweaver for coding PHP, and I always have. It has php syntax highlighting and all that jazz. However, you are right when you say it generates bad code. It generates craptastic code, but as long as you are hand writing all your code then you will be fine. Dreamweaver is still on of my favorite IDE's, for web development anyways

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.