Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Conditional statement ASP

New Here ,
Jan 04, 2008 Jan 04, 2008
I want to show information from a database using 2 WHERE statements.
WHERE cat='restaurant'
WHERE show='True'
I have it working to show cat but I also want it to show information based on show as well.
I tried WHERE cat='restaurant' AND show='True'
but it did not work.
What I am doing is setting up a form so when anyone adds anything it will not show until I authorise it. The initial state for show is False.
Are there any tutorials for this.
Thanks.
TOPICS
Server side applications
539
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 04, 2008 Jan 04, 2008
sccs wrote:
> I want to show information from a database using 2 WHERE statements.
> WHERE cat='restaurant'
> WHERE show='True'
> I have it working to show user but I also want it to show information based on
> mail as well.
> I tried WHERE cat='restaurant' AND show='True'
> but it did not work.
> What I am doing is setting up a form so when anyone adds anything it will not
> show until I authorise it. The initial state for show is False.
> Are there any tutorials for this.
> Thanks.
>

When you wrap True like this 'True' it is treating it as string, not a
boolean condition, all you need to do is drop the quotes so it is like this:

WHERE cat = 'restaurant' AND show = True

Steve
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 04, 2008 Jan 04, 2008
Thanks. I will give that a go.
On another note.
When a user submits a form from my site it adds it to the database as wanted. I then send the user to a confirm page. That page then sends me an e-mail to say a form has been filled in and added to the database. Is there a way of adding the senders name taken from the form to the email.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 04, 2008 Jan 04, 2008
sccs wrote:
> Thanks. I will give that a go.
> On another note.
> When a user submits a form from my site it adds it to the database as wanted.
> I then send the user to a confirm page. That page then sends me an e-mail to
> say a form has been filled in and added to the database. Is there a way of
> adding the senders name taken from the form to the email.
>

Yes there is a way, I will attempt to help you.

You need to get the form field value that is submitted to the update
page sent to the confirm page. You can either use a Session variable, or
a QueryString variable. I think its easier to use a Session variable.

On the update page, before the update function itself, probably good
idea to place it right at the top of the page. Something like this:

<%
Session("SendersName") = Request.Form("SendersName")
%>

This will make the name available to you during your session, so on the
page with the email code, you can access this data using this:

<%= Session("SendersName") %>

Without seeing your code for the email I can't really show you how to
use it.

Steve
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 04, 2008 Jan 04, 2008
Hi
This is the code for the email form. I can get the session variable info to show on the page but can't get it to email the variable.
Thanks for your help.


**************CODE*************

'Set the response buffer to true so we execute all asp code before sending the HTML to the clients browser
Response.Buffer = True

'Dimension variables
Dim strBody 'Holds the body of the e-mail
Dim objCDOMail 'Holds the mail server object
Dim strMyEmailAddress 'Holds your e-mail address
Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want to send carbon copies of the e-mail
Dim strBCCEmailAddress 'Holds any blind copy e-mail addresses if you wish to send blind copies of the e-mail
Dim strReturnEmailAddress 'Holds the return e-mail address of the user


'----------------- Place your e-mail address in the following sting ----------------------------------

strMyEmailAddress = "me@someemail.co.uk"

'----------- Place Carbon Copy e-mail address's in the following sting, separated by ; --------------

strCCEmailAddress = "" 'Use this string only if you want to send the carbon copies of the e-mail

'----------- Place Blind Copy e-mail address's in the following sting, separated by ; --------------

strBCCEmailAddress = "" 'Use this string only if you want to send the blind copies of the e-mail

'-----------------------------------------------------------------------------------------------------


'Initialse strBody string with the body of the e-mail
strBody = "<h2>ADVERT ADDED ON THE JUST ARRIVED SA WEBSITE</h2>"
strBody = strBody & "<br><b>Just to inform you that an advert has been added to the Just Arrived SA website. </b>" & Request.Form("BName")
strBody = strBody & "<br><b>Go to <a href="" http://www.justarrived-sa.com.asp"" target=""_blank"">www.justarrived-sa.com.asp</a> to authorise this advert. </b>" & Request.Form("Go to <a href="" http://www.justarrived-sa.com.asp"" target=""_blank"">www.justarrived-sa.com.asp</a> to authorise this advert.")


'Send the e-mail

'Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

'Who the e-mail is from (this needs to have an e-mail address in it for the e-mail to be sent)
objCDOMail.From = Request.Form("NAME") & " <" & strMyEmailAddress & ">"

'Who the e-mail is sent to
objCDOMail.To = strMyEmailAddress

'Who the carbon copies are sent to
objCDOMail.Cc = strCCEmailAddress

'Who the blind copies are sent to
objCDOMail.Bcc = strBCCEmailAddress

'Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0

'Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0

'Set the subject of the e-mail
objCDOMail.Subject = "Enquiry sent from enquiry form on Just Arrived-SA website"

'Set the main body of the e-mail
objCDOMail.Body = strBody

'Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1

'Send the e-mail
objCDOMail.Send

'Close the server object
Set objCDOMail = Nothing
%>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 07, 2008 Jan 07, 2008
Somethings not quite right somewhere.

In here:

'Initialse strBody string with the body of the e-mail
strBody = "<h2>ADVERT ADDED ON THE JUST ARRIVED SA WEBSITE</h2>"
strBody = strBody & "<br> Just to inform you that an advert has been
added
to the Just Arrived SA website.
" & Request.Form("BName")
strBody = strBody & "<br> Go to <a
href="" http://www.justarrived-sa.com/ADMIN.asp""
target=""_blank"">www.justarrived-sa.com/ADMIN.asp</a> to authorise this
advert.
" & Request.Form("Go to <a
href="" http://www.justarrived-sa.com/ADMIN.asp""
target=""_blank"">www.justarrived-sa.com/ADMIN.asp</a> to authorise this
advert.")

You have a second Request.Form which looks wrong, its go more HTML in it.

Can you show me what the email contains when it does get sent to you?

Steve
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 07, 2008 Jan 07, 2008
The email says:
Just to inform you that an advert has been added to the Just Arrived SA website.
Go to http://www.justarrived-sa.com/ADMIN.asp to authorise this advert.

What I did was copy the script from one I have for sending an email form. I may not have copied it correctly.
Thanks for your help.
Andy
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 07, 2008 Jan 07, 2008
LATEST
sccs wrote:
> The email says:
> Just to inform you that an advert has been added to the Just Arrived SA
> website.
> Go to http://www.justarrived-sa.com/ADMIN.asp to authorise this advert.
>
> What I did was copy the script from one I have for sending an email form. I
> may not have copied it correctly.
> Thanks for your help.
> Andy
>

Ok, as a test change this:

strBody = "<h2>ADVERT ADDED ON THE JUST ARRIVED SA WEBSITE</h2>"
strBody = strBody & "<br> Just to inform you that an advert has been
added
to the Just Arrived SA website.
" & Request.Form("BName")
strBody = strBody & "<br> Go to <a
href="" http://www.justarrived-sa.com/ADMIN.asp""
target=""_blank"">www.justarrived-sa.com/ADMIN.asp</a> to authorise this
advert.
" & Request.Form("Go to <a
href="" http://www.justarrived-sa.com/ADMIN.asp""
target=""_blank"">www.justarrived-sa.com/ADMIN.asp</a> to authorise this
advert.")

To this:

strBody = Session("BName")

Thats how you access a session variable...thats as long as you set it in
the first place :)

Steve
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines