Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

php form

Featured Replies

Hi after some advice i have created a cancellation form for a client and the last 3 options are 1 month 2 months and 3 months. after the form is submitted the user gets a modial pop up with the message

 

your campaign will be suspended for xxx months as per your request. Your account will automatically go back live in xxx mnths from your next renewal date. One of our agents will be in contact with you shortly to confirm all details. Thank you for your business.

 

would it be possible to make the xxx say 1 month 2months ect

 

basically i need the form to pickup wich option they chose and display it in the thankyou message

 

could this be achived with php

Hi after some advice i have created a cancellation form for a client and the last 3 options are 1 month 2 months and 3 months. after the form is submitted the user gets a modial pop up with the message

 

your campaign will be suspended for xxx months as per your request. Your account will automatically go back live in xxx mnths from your next renewal date. One of our agents will be in contact with you shortly to confirm all details. Thank you for your business.

 

would it be possible to make the xxx say 1 month 2months ect

 

basically i need the form to pickup wich option they chose and display it in the thankyou message

 

could this be achived with php

mmmm yes all u need to do is echo what ever variables go with those options :) if its a pop up using javascript u actually can pass php variables through a js function as parameters.

I don't understand the question, you want to know if this can be done in PHP? if so then yes it can.

I don't understand the question, you want to know if this can be done in PHP? if so then yes it can.

i think he means hes trying to use a javascript popup and if u can run the php within the popup, or show the results from the form with it, atleast thats what i gathered :)

  • Author

i think he means hes trying to use a javascript popup and if u can run the php within the popup, or show the results from the form with it, atleast thats what i gathered :)

yeah i need to show the result of the clients choice once the form has been submitted in the thank you message [example] they ticked option 1 suspend for 1 month

 

i need the option that they ticked to display in the message

 

your campaign will be suspended for 1 month as per your request. Your account will automatically go back live in 1 month from your next renewal date. One of our agents will be in contact with you shortly to confirm all details. Thank you for your business.

 

sorry for my poor explaination :)

  • Author

after submitting my form to sendmail.php and message sent jquery kicks in with no page refresh and displays a <div id"sent"> with my message on the same page. what i am trying to achive is to display data from the form below on the same page

 

<form action="sendmail1.php" method="post">
			                <fieldset>

                                       <li>
                                          <label for="suspend-account" class="name">Suspend your account</label>
                                          <select name="item"> 
                                          <option>1 Month</option>
                                          <option>2 Months</option>
                                          <option>3 Months</option>
                                          </select>




                                        <li>
			                            <label for="reason-for-cancellation" class="name">Reason for cancellation</label>
			                            <textarea name="reason-for-cancellation" id="reason-for-cancellation" class="required"></textarea>
			                        </li>

			                        <li>
			                        	<label for="submit" class="name"> </label>
			                            <input type="submit" id="submit" value="Submit" />
			                            <input type="hidden" name="submitted" id="submitted" value="true" />
			                        </li>

			                    </ol>
			                </fieldset>
			            </form>

			            <div id="sent">
			                <h3>Your message has been sent!</h3>
			                <?php


echo "you would like to suspend your account for  " . $item . ".<br />";</div>

 

any ideas i am really stuck help :sorry: :sorry: :sorry: :sorry: :sorry:

Edited by Sjackson

  • Author

any ideas wrecking my brains :(

If there's no page refresh when submitting the form, the how about using a javascript onsubmit handler (like you would for JS form validation) to set the number of months as a javascript variable which you can then pass to the jQuery pop-up message?

  • Author

thanks spitfire :) so would the javascript display the data in my div ? any ideas of a tutorial on the web to do this

Here's an example of onsubmit picking up form data - w3schools.com/jsref/event_form_onsubmit.asp

 

Shouldn't be too hard to get it to get it into your div. It depends on how your current form submission works, but you should be able to do it through javasscript with document.write or inserting the text through jQuery.

 

Is the code you posted above the exact code you use for the form?

  • Author

// Contact Form
    // ---------------------------------------------------------

    //Define URL to PHP mail file
    url = "sendmail1.php";

    //Activate $ form validation
    $("#jsk-contact").validate({

        submitHandler: function() {

            //Define data string
            var datastring = $("#jsk-contact").serialize();

            //Submit form
            $.ajax({
                type: "POST",
                url: url,
                data: datastring,
                success: function(){
                        $('#jsk-contact').slideUp();
                        $('#sent').fadeIn();

                }
            });
        }

    });

    // ---------------------------------------------------------

 

thats the jquery what code will i need to add to display the form data that i need

Edited by Sjackson

If you gave the select list that they choose the number of months with an id of #suspend-account then you could probably do it by changing the jQuery to:

 

//Define data string
var datastring = $("#jsk-contact").serialize();
var month = $("#suspend-account").val();

//Submit form
$.ajax({
       type: "POST",
       url: url,
data: datastring,
success: function(){
	$('#sent').html('<h3>Your message has been sent!</h3><p>You would like to suspend your account for'+ month +'</p>');
	$('#jsk-contact').slideUp();
	$('#sent').fadeIn();
}

 

 

Just to warn you, I haven't tested that code so apologies for any mistakes or typos!

 

 

Also, the above is an easy way to do what you want but it isn't technically the best way. Ideally, you'd want to make the sendmail.php script return the number of months after successfully sending the e-mail and then pick that returned value up in the 'success: function()' part of the jQuery, which you could then output to the browser. A bit more coding work but more valid code in the end.

Edited by Spitfire

  • Author

thanks spitfire i will give it a go :):clapping: :clapping: :clapping: :clapping:

  • Author

it did work spitfire sort of it displays the message but keeps displaying 1 month only any ideas thanks for the suggestion :)

Edited by Sjackson

D'oh! Thought I missed something.

 

This:

var month = $("#suspend-account").val();

 

Should be:

var month = $("#suspend-account option:selected").val();

  • Author

D'oh! Thought I missed something.

 

This:

var month = $("#suspend-account").val();

 

Should be:

var month = $("#suspend-account option:selected").val();

 

get this now You would like to suspend your account forundefined

Your select element only has a name attribute of item.

Give it an id of monthselect and change spitfire's code to

var month = $("#monthselect").val();

  • Author

big massive thanks to you both spitfire and elanman thats it its working couldent thank you enough :drinks: :drinks: :drinks: :drinks: :drinks: :drinks: realy appriciate it

Edited by Sjackson

Good stuff :)

Although it is working, might I recommend a change to the 'id' attribute on the select?

As your label element has a 'for' attribute of suspend-account and this label is associated with the select element, the select element should have an id of suspend-account, (not monthselect, which I made up). Sorry about that, I posted earlier without a proper look.

So your new html should be like:

<label for="suspend-account" class="name">Suspend your account</label>
                                      	<select name="item" id="suspend-account"> 
                                      	<option>1 Month</option>
                                      	<option>2 Months</option>
                                      	<option>3 Months</option>
                                      	</select>

and your line of js this:

var month = $("#suspend-account").val();

which means your for attribute now has a purpose :)

Edited by ElanMan

  • 2 weeks later...
  • Author

if non of the options was selected how can i hide the message any ideas

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.