2

My newbie question of the day is....

I have a comment function on my site that I have 3 versions of for the same page. I have one that has specific traits for A. signed in and looking at own profile B. signed in looking at someone elses profile C. Not signed in at all

I have it working just great depending on what criteria the user falls under. I have a submit button that sends one of these formats, so my question is, how do I toggle (in this case two,because C. does not require a button) two different buttons for the same if(isset chunk?

Here is what I am wanting to add onto/alter:

if(isset($_POST['commentProfileSubmit']) && $auth) {
3
  • Please be a bit more specific. Where do you store the ID of the profile the user it currently at? Where is the current users ID? Commented Jan 21, 2010 at 23:23
  • What do you mean by toggle in this context? Commented Jan 21, 2010 at 23:25
  • @fireeyedboy I mean, when the user falls under the B. criteria, the form is going to be sent somewhere else (require a different post value) than if the user falls under the A. criteria. Commented Jan 21, 2010 at 23:35

2 Answers 2

2

Not sure if this is what you need, but:

in the html markup, use something like

<input type="submit" name="commentProfileSubmit" value="<?= $pageVersion ?>" />

, $pageVersion stand for the variable/value you use to determine your page version.

Then in php, you have

if (isset($_POST['commentProfileSubmit'])) {
switch ($_POST['commentProfileSubmit']) {
case 'A':
    echo 'from A';
    break;

case 'B':
    echo 'from B';
    break;
}
Sign up to request clarification or add additional context in comments.

Comments

1

Do you mean you have two (or more) submit buttons for the same form? Give each button unique name:

<input type="submit" value="Button A" name="button_a" />
<input type="submit" value="Button B" name="button_b" />

And in php check the POST value:

if(isset($_POST['button_a'])){
    echo 'Button A clicked';
}else if(isset($_POST['button_b'])){
    echo 'Button B clicked';
}

If I understood your question correctly...

1 Comment

basically, I have a a chunk of code that has 3 different text areas/submit buttons

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.