Alex's Support Forums » Hacks

Rename an existing contact form field (Lite)

(4 posts)
  • Started 4 months ago by maskingshadows
  • Latest reply from Alex
  1. maskingshadows
    Member

    Hello, I am very new to PHP, and I need to add a form element called "Birth Date". I have absolutely no idea how to do this, and I would appreciate any help. I also have another question. I am trying to add this form to a website for my father... The website is www.LearnMagicEasy.com, as you see I want to integrate it on the home page, index.html. I was wondering how I go about doing this. All thanks goes to Alex for this free form creator!

    -Ken

    Posted 4 months ago #
  2. Hi Ken,

    simpleContact 1.2 does not support custom fields, but there is a workaround you could do. You could take a field that you don't use (e.g. company) and change its label. That will give you a text field labeled 'Birth date':

    Changing to Birth date

    Open sc_admin/includes/contact/build.php

    On line 50, find where it says Company</label> and replace it with Birth date</label>

    Open sc_admin/message.php

    On line 65, find <strong>Company:</strong> and replace it with <strong>Birth date:</strong>

    That should do it. Obviously, your database and form code will still refer to a company field, but unless the user goes poking around in your HTML code they will never know.

    Integrating the form into your site

    Firstly, you need to rename your index.html page to index.php (this is so the code will execute). You may need to fix some links around your website after doing this.

    Open contact.php

    You will see some PHP code at the top of the page. Copy this into your page, making sure the paths are correct.

    Copy the form into your page, from the opening <form> tag to the closing </form> tag.

    Now try looking at the page on your website. You should see your form.

    Posted 4 months ago #
  3. maskingshadows
    Member

    Okay, first of all... THANKS FOR THE INSTANT REPLY! You really know what you're doing and you're very helpful! So thank you! Okay, I got the PHP form on the index page and renamed company to birth date. Now, I can't figure out how to change the look of the contact form now that it is integrated with index.php. Take a look, www.LearnMagicEasy.com, how can I change the color, text and format of the form? I really appreciate your help.

    -Ken

    Posted 4 months ago #
  4. Thanks, but I have to confess that I missed a couple of points :*)

    This workaround is straightforward, but this is the first time I've outlined it in a forum post so please forgive the omissions. I'll look at gathering it into a help document when I have the time. Moving on...

    The form must post to itself

    Open your index.php file, and change the action value on the form tag from contact.php to index.php

    Fixing the validation message

    Open sc_admin/includes/contact/posted.php

    Find where it says Please enter your company and replace it with Please enter your birth date. This makes the form show an appropriate message if the user doesn't complete the field.

    Styling the form

    I can see by viewing the source of your index.php page that you are familiar with CSS. I forgot to mention that you need to paste a link to simpleContact's CSS file into your head.

    Open contact.php and look in the head. Find where it says:

    <link rel="stylesheet" type="text/css" media="screen" href="screen.css" />

    Paste that into your index.php before the closing </head> tag. Make sure that the CSS file is uploaded.

    You will probably want to remove the CSS instructions that are making the form background white. Since you're using a blue background I'd recommend making the labels white and the error messages yellow (removing the arrows too).

    You can now remove contact.php from your web server - you don't need it.

    Hope this helps.

    Posted 4 months ago #

RSS feed for this topic

Reply

You must log in to post.