When a man becomes sexually excited, muscles in their penis relax. This relaxation allows for increased blood flow through the penile arteries. This blood fills two chambers inside the penis called the corpora cavernosa. As the chambers fill with blood, the penis grows rigid. Erection ends when the muscles contract and the accumulated blood can flow out through the penile veins.
Although not proven, it is likely that erectile dysfunction can be prevented by good general health, paying particular attention to body weight, exercise, and cigarette smoking. For example, heart disease and diabetes are problems that can cause erectile dysfunction, and both are preventable through lifestyle changes such as sensible eating and regular exercise. Furthermore, early diagnosis and treatment of associated conditions like diabetes, hypertension and high cholesterol may prevent or delay erectile dysfunction, or stop the erectile dysfunction from getting more serious.
Injection therapy involves injecting a substance into the penis to enhance blood flow and cause an erection. The Food and Drug Administration (FDA) approved a drug called alprostadil (Caverject) for this purpose in July of 1995. Alprostadil relaxes smooth muscle tissue to enhance blood flow into the penis. It must be injected shortly before intercourse. Another, similar drug that is sometimes used is papaverine—not yet been approved by the FDA for this use. Either drug may sometimes cause painful erections or priapism (uncomfortable, prolonged erections) that must be treated with a shot of epinephrine.
Herbal supplements such as ginkgo biloba, saw palmetto, and yohimbe have been touted as sexual enhancers, and some men have been tempted to try them to treat erectile dysfunction. Bennett warns, however, that none has been approved by the FDA or even shown by any reliable studies to prevent, treat, or improve erectile dysfunction. Moreover, supplements are unregulated and can have many side effects or interfere with prescribed medications you’re already taking. Don’t jeopardize your health by taking a supplement to treat erectile dysfunction without first talking with your doctor.
With an inflatable implant, fluid-filled cylinders are placed lengthwise in the penis. Tubing joins these cylinders to a pump placed inside the scrotum (between the testicles). When the pump is engaged, pressure in the cylinders inflate the penis and makes it stiff. Inflatable implants make a normal looking erection and are natural feeling for your partner. Your surgeon may suggest a lubricant for your partner. With the implant, men can control firmness and, sometimes, the size of the erection. Implants allows a couple to be spontaneously intimate. There is generally no change to a man's feeling or orgasm.
Risks associated with injection therapy including bleeding, pain with injection, penile pain, priapism, and corporal fibrosis (scarring inside of the corpora cavernosa). There is also concern that repetitive injections in the same area could cause scar tissue to build up in the tunica albuginea that could create penile curvature. Thus, doctors recommended that one alternate sides with injection and perform injections no more frequent than every other day.
In a prospective study from the Prostate Cancer Prevention Trial database, Thompson et al reported that men presenting with ED had a significantly higher chance of developing a cardiovascular event over a 7-year follow-up period.  The hazard ratio was 1.45, which is in the range of risk associated with current smoking or a family history of MI.
Following a detailed discussion about the history of erectile dysfunction and its risk factors, your doctor will examine the testicles and penis to help determine the cause of erectile dysfunction. Your doctor will check reflexes and pulses in the area to see if problems with blood vessels or nerves are contributing to the erectile dysfunction. If necessary, your doctor will order tests to help diagnose erectile dysfunction.
This is similar to magnetic resonance imaging. Magnetic resonance angiography uses magnetic fields and radio waves to provide detailed images of the blood vessels. Doctors may inject a "contrast agent" into the person's bloodstream that causes vascular tissues to stand out against other tissues. The contrast agent provides for enhanced information regarding blood supply and vascular anomalies.
Picture of penile tumescence monitor. This penile tumescence monitor is placed at the base and near the corona of the penis. It is connected to a monitor that records a continuous graph depicting the force and duration of erections that occur during sleep. The monitor is strapped to the leg. The nocturnal penile tumescence (NPT) test is conducted on several nights to obtain an accurate indication of erections that normally occur during the alpha phase of sleep.
If you can't take one of these oral medications, your physician may have you try Caverject (alprostadil for injection), a hormone that you inject into your penis using a fine needle, or Muse (alprostadil urogenital), a tiny suppository that you insert into the tip of the penis. Both of these will bring on an erection within five to 15 minutes without sexual stimulation.
Both ED and low testosterone (hypogonadism) increase with age. The incidence of the latter is 40% in men aged 45 years and older.  Testosterone is known to be important in mood, cognition, vitality, bone health, and muscle and fat composition. It also plays a key role in sexual dysfunction (eg, low libido, poor erection quality, ejaculatory or orgasmic dysfunction, reduced spontaneous erections, or reduced sexual activity). 
In this study, ED proceeded CVD in almost 70% of cases. Similarly, many men with ED have been found to have pre-existing CVD. A study by Vlachopoulos et al evaluated the incidence of asymptomatic CVD in 50 men with ED.22 These authors found that 19% of men with ED had asymptomatic CVD. Similarly, Mulhall and colleagues found that 20% of men presenting with ED and vascular insufficiency on penile duplex had asymptomatic CVD.23
Prior to the introduction of PDE5i in 1998, intracavernosal vasoactive medications and penile implant surgery were the mainstays of treatment. Penile implant surgery involves placement of inflatable or malleable rods within the corpora cavernosa to provide rigidity for intercourse. Choice of which implant to place usually depends upon manual dexterity and function of the patient, patient anatomy, physician preference and surgical approach.
The PDE5 inhibitors sildenafil (Viagra), vardenafil (Levitra) and tadalafil (Cialis) are prescription drugs which are taken orally.:20–21 Additionally, a cream combining alprostadil with the permeation enhancer DDAIP has been approved in Canada as a first line treatment for erectile dysfunction. Penile injections, on the other hand, can involve one of the following medications: papaverine, phentolamine, and prostaglandin E1, also known as alprostadil.:25
It is important to understand that ED is frequently, if not usually, directly related to endothelial dysfunction, and that the release of NO by the vasculature of the penile arteries is directly related to the function of intact, healthy endothelium. In the face of endothelial dysfunction, the process of erection fails to occur in a normal fashion.16
Before taking any medication for erectile dysfunction, including over-the-counter supplements and herbal remedies, get your doctor's OK. Medications for erectile dysfunction do not work in all men and might be less effective in certain conditions, such as after prostate surgery or if you have diabetes. Some medications might also be dangerous if you:
A physical exam checks your total health. Examination focusing on your genitals (penis and testicles) is often done to check for ED. Based on your age and risk factors, the exam may also focus on your heart and blood system: heart, peripheral pulses and blood pressure. Based on your age and family history your doctor may do a rectal exam to check the prostate. These tests are not painful. Most patients do not need a lot of testing before starting treatment.